:root {
  --bg: #f7f8f5;
  --ink: #171918;
  --muted: #60665f;
  --panel: #ffffff;
  --panel-strong: #f0f3ed;
  --line: #d9ded5;
  --line-strong: #b7c0b1;
  --terran: #2d72d9;
  --protoss: #c8901b;
  --zerg: #a24373;
  --good: #2b9465;
  --warn: #c9573f;
  --focus: #111111;
  --shadow: 0 20px 55px rgba(24, 28, 24, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  color: var(--ink);
  background: var(--bg);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(247, 248, 245, 0.96) 330px),
    radial-gradient(circle at 8% 0%, rgba(45, 114, 217, 0.16), transparent 280px),
    radial-gradient(circle at 92% 10%, rgba(201, 87, 63, 0.14), transparent 300px),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(17, 17, 17, 0.2);
  outline-offset: 3px;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin-inline: auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 0 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand-mark span {
  position: absolute;
  width: 19px;
  height: 4px;
  border-radius: 999px;
  background: var(--ink);
}

.brand-mark span:nth-child(1) {
  transform: rotate(0deg) translateY(-9px);
  background: var(--terran);
}

.brand-mark span:nth-child(2) {
  transform: rotate(120deg) translateY(-9px);
  background: var(--protoss);
}

.brand-mark span:nth-child(3) {
  transform: rotate(240deg) translateY(-9px);
  background: var(--zerg);
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-transform: uppercase;
}

.brand-name {
  display: block;
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 850;
  line-height: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.memory-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.tool-button,
.text-button,
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 800;
}

.tool-button,
.copy-button {
  padding: 0 12px;
}

.tool-button svg,
.copy-button svg,
.search-box svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.text-button {
  min-height: 30px;
  padding: 0 9px;
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 0.78rem;
}

.text-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.layout {
  display: grid;
  grid-template-columns: minmax(290px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.control-panel,
.answer-area {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.control-panel {
  position: sticky;
  top: 14px;
  overflow: hidden;
}

.panel-section {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-section:last-child {
  border-bottom: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.split-heading {
  justify-content: space-between;
}

.split-heading h2 {
  margin-right: auto;
}

.step {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 850;
}

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

h2 {
  font-size: 0.98rem;
  line-height: 1.2;
}

h3 {
  font-size: 1rem;
  line-height: 1.25;
}

.race-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.race-button {
  position: relative;
  display: grid;
  min-height: 78px;
  padding: 10px 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
}

.race-button[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow: inset 0 -3px 0 var(--race);
}

.race-token {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-bottom: 8px;
  border-radius: 7px;
  background: #eef3f8;
  color: var(--race);
  font-size: 0.92rem;
  font-weight: 900;
}

.race-label {
  display: block;
  font-size: 0.86rem;
  font-weight: 850;
  line-height: 1.1;
}

.race-sub {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

.threat-grid {
  display: grid;
  gap: 8px;
}

.threat-button {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 58px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
}

.threat-button[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--panel-strong);
}

.threat-name {
  font-size: 0.9rem;
  font-weight: 850;
  line-height: 1.15;
}

.threat-meta {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.25;
}

.empty-state {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  margin-bottom: 10px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.unit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.unit-button {
  display: grid;
  grid-template-rows: 44px minmax(24px, auto);
  gap: 6px;
  align-items: start;
  justify-items: center;
  min-width: 0;
  min-height: 78px;
  padding: 7px 5px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 850;
  line-height: 1.08;
  text-align: center;
}

.unit-button[aria-pressed="true"] {
  border-color: var(--unit-color);
  background: #f7fbff;
  box-shadow:
    inset 0 0 0 2px var(--unit-color),
    0 8px 18px rgba(23, 25, 24, 0.12);
}

.unit-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #111;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 900;
}

.unit-icon img {
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  object-fit: contain;
  display: block;
}

.unit-name {
  display: block;
  width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}

.answer-area {
  min-height: 640px;
  padding: 22px;
}

.answer-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.match-title {
  display: grid;
  gap: 8px;
}

.match-title h1 {
  max-width: 720px;
  font-size: 2.15rem;
  line-height: 1.02;
}

.match-title p {
  max-width: 700px;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.answer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(250px, 0.88fr);
  gap: 16px;
  align-items: start;
}

.answer-block {
  display: grid;
  gap: 12px;
}

.plan-band {
  display: grid;
  gap: 13px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.plan-band.strong {
  border-color: #a9d8c0;
  background:
    linear-gradient(90deg, rgba(43, 148, 101, 0.12), transparent 52%),
    var(--panel);
}

.band-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.band-heading span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.unit-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.unit-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 800;
}

.unit-pill.priority {
  border-color: #8bc9aa;
  background: #e8f6ef;
}

.note-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.note-list li {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  gap: 9px;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.45;
}

.note-list li::before {
  content: "";
  width: 9px;
  height: 9px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--good);
}

.note-list.warn li::before {
  background: var(--warn);
}

.tactical-map {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: end;
  gap: 8px;
  min-height: 155px;
  padding: 15px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(23, 25, 24, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 25, 24, 0.05) 1px, transparent 1px),
    #fbfcfa;
  background-size: 36px 36px;
}

.tactical-map::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(23, 25, 24, 0.08);
  border-radius: 50%;
}

.map-unit {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: end;
  justify-items: center;
  gap: 8px;
  min-width: 0;
}

.map-dot {
  width: 28px;
  height: 28px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--unit-color, var(--good));
  box-shadow: 0 8px 18px rgba(23, 25, 24, 0.16);
  transform: rotate(45deg);
}

.map-label {
  width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 850;
  line-height: 1.15;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.read-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid #dfc47c;
  border-radius: 8px;
  background: #fbf2d9;
  color: var(--ink);
}

.read-banner p {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 760;
  line-height: 1.35;
}

.unit-insights {
  display: grid;
  gap: 10px;
}

.insight-card {
  display: grid;
  gap: 9px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.insight-card header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.insight-card h3 {
  font-size: 0.96rem;
}

.tag {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.insight-card p {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.metric-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 0.7fr) minmax(0, 1.6fr);
  gap: 10px;
}

.metric {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric strong {
  font-size: 1.15rem;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.metric.text-metric strong {
  font-size: 0.96rem;
  line-height: 1.28;
}

.metric span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 760;
  line-height: 1.25;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0 24px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

#saveStatus {
  min-width: 130px;
  text-align: right;
}

.is-hidden {
  display: none;
}

@media (max-width: 920px) {
  .layout,
  .answer-grid {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }

  .answer-area {
    min-height: 0;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 22px, 1180px);
  }

  .app-header,
  .answer-top,
  .footer {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    justify-content: stretch;
  }

  .memory-pill,
  .tool-button {
    flex: 1 1 auto;
  }

  .race-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .unit-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .answer-area,
  .panel-section {
    padding: 14px;
  }

  .match-title h1 {
    font-size: 1.7rem;
  }

  .read-banner {
    align-items: stretch;
    flex-direction: column;
  }

  #saveStatus {
    min-width: 0;
    text-align: left;
  }
}
