:root {
  color-scheme: dark;
  --bg: #101417;
  --panel: #171d21;
  --panel-2: #20272d;
  --line: #344049;
  --muted: #9aa9b5;
  --text: #f2f6f8;
  --accent: #3fb58a;
  --accent-2: #e6b24a;
  --danger: #e76f64;
  --water: #4f9ce8;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid transparent;
  border-radius: 7px;
  min-height: 38px;
  padding: 0 13px;
  color: #07110d;
  background: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  filter: brightness(1.08);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0f1418;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.45;
}

label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.88rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  height: 78px;
  padding: 6px 16px;
  border-bottom: 1px solid #242d33;
  background: #12181c;
  overflow: visible;
  position: relative;
  z-index: 10;
}

.brand-block {
  display: flex;
  align-items: center;
  flex: 0 0 250px;
  min-width: 250px;
  height: 78px;
  overflow: visible;
}

.topbar h1 {
  margin: 0;
  line-height: 0;
}

.brand-logo {
  display: block;
  width: 240px;
  height: auto;
  max-width: none;
  max-height: none;
  object-fit: contain;
  object-position: left center;
  flex-shrink: 0;
  transform: translateY(-2px);
}

.rules {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.eyebrow,
.section-head p {
  margin: 0;
  color: var(--muted);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
  color: var(--accent-2);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.76rem;
}

.eyebrow img {
  width: 19px;
  height: 19px;
}

.rules {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: #11171b;
  color: #d7e4ea;
  font-size: 0.78rem;
  font-weight: 900;
  text-decoration: none;
}

.top-link:hover,
.top-link.active {
  border-color: rgba(63, 181, 138, 0.6);
  background: rgba(63, 181, 138, 0.12);
  color: #ffffff;
}

.format-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0;
  background: #11171b;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.format-label {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  border-right: 1px solid rgba(52, 64, 73, 0.82);
  color: #9fb1bc;
  letter-spacing: 0.01em;
}

.format-button {
  position: relative;
  min-width: 178px;
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  padding: 0 34px 0 12px;
  background: transparent;
  color: #f2f7fa;
  font-size: 0.78rem;
  font-weight: 900;
  outline: none;
  text-align: left;
}

.format-button:hover,
.format-button:focus-visible {
  background: rgba(63, 181, 138, 0.08);
  box-shadow: inset 0 0 0 1px rgba(63, 181, 138, 0.42);
  filter: none;
}

.format-button::after {
  content: "";
  position: absolute;
  right: 13px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid #a9bac4;
  border-bottom: 2px solid #a9bac4;
  transform: translateY(-65%) rotate(45deg);
}

.format-menu {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 50;
  display: grid;
  gap: 3px;
  min-width: 100%;
  padding: 5px;
  border: 1px solid #40505b;
  border-radius: 9px;
  background: #11181c;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
}

.format-menu[hidden] {
  display: none;
}

.format-option {
  justify-content: flex-start;
  min-height: 32px;
  border: 0;
  border-radius: 7px;
  padding: 0 10px;
  background: transparent;
  color: #d9e5ea;
  font-size: 0.78rem;
  font-weight: 850;
  text-align: left;
}

.format-option:hover,
.format-option.active {
  background: #203039;
  color: #ffffff;
  filter: none;
}

.format-option.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.language-control .format-button {
  min-width: 92px;
}

.language-control .format-menu {
  min-width: 150px;
}

.rules > span,
.tag,
.type-pill,
.role-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  background: #11171b;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(290px, 0.95fr) minmax(380px, 1.25fr) minmax(310px, 1fr) minmax(310px, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "team editor suggestions counters"
    "team editor suggestions threat";
  gap: 16px;
  height: calc(100vh - 78px - 26px);
  overflow: hidden;
  padding: 12px clamp(12px, 3vw, 32px);
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 26px;
  padding: 0 10px;
  border-top: 1px solid #242d33;
  background: #10161a;
  color: #8999a4;
  font-size: 0.72rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-footer span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-footer a {
  color: #a9d7c7;
  text-decoration: none;
  font-weight: 800;
}

.site-footer a:hover {
  color: #ffffff;
}

.about-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
}

.about-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 34px;
  flex: 1 0 auto;
}

.about-page .site-footer {
  flex: 0 0 26px;
}

.about-hero {
  margin-bottom: 18px;
  border-bottom: 1px solid #283139;
  padding-bottom: 18px;
}

.about-hero h2 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 5vw, 3.3rem);
  line-height: 1;
}

.about-hero p {
  max-width: 860px;
  margin: 8px 0 0;
  color: #c8d5dc;
  line-height: 1.55;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.about-card {
  border: 1px solid #283139;
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.about-card h3 {
  margin: 0 0 7px;
  font-size: 1.05rem;
}

.about-card h3[lang="en"] {
  margin-top: 16px;
}

.about-card p {
  margin: 0;
  color: #c8d5dc;
  line-height: 1.5;
}

.about-card a {
  color: #8fe1c2;
  font-weight: 900;
}

.panel {
  min-height: 0;
  background: var(--panel);
  border: 1px solid #283139;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px;
}

.team-panel {
  grid-area: team;
}

.editor-panel {
  grid-area: editor;
}

.editor-panel #editor {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.suggestions-panel {
  grid-area: suggestions;
}

.threat-panel {
  grid-area: threat;
}

.counters-panel {
  grid-area: counters;
}

.team-panel,
.editor-panel,
.suggestions-panel,
.threat-panel,
.counters-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.suggestions-panel .suggestions,
.threat-panel .counters,
.counters-panel .counters {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  padding-right: 4px;
}

.counters-panel .counters {
  flex: 1;
}

.threat-panel .counters {
  flex: 1;
}

.suggestions-panel .suggestions::-webkit-scrollbar,
.threat-panel .counters::-webkit-scrollbar,
.counters-panel .counters::-webkit-scrollbar,
.import-tray textarea::-webkit-scrollbar {
  width: 8px;
}

.suggestions-panel .suggestions::-webkit-scrollbar-thumb,
.threat-panel .counters::-webkit-scrollbar-thumb,
.counters-panel .counters::-webkit-scrollbar-thumb,
.import-tray textarea::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #3a4650;
}

.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  margin-bottom: 10px;
}

.section-head h2 {
  font-size: 1.08rem;
}

.ghost-button {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.accent-button {
  background: var(--accent-2);
}

.random-button {
  border-color: rgba(230, 178, 74, 0.72);
  background: rgba(230, 178, 74, 0.16);
  color: #ffe0a0;
}

.random-button:hover {
  background: rgba(230, 178, 74, 0.28);
  filter: none;
}

.quick-add {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  flex-shrink: 0;
  margin-bottom: 8px;
}

.team-actions,
.import-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.team-actions button {
  min-height: 34px;
  padding-inline: 10px;
}

.modal-open {
  overflow: hidden;
}

body.modal-open::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(5, 8, 10, 0.72);
  backdrop-filter: blur(3px);
}

.import-tray {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 100;
  display: grid;
  gap: 10px;
  width: min(680px, calc(100vw - 32px));
  max-height: min(680px, calc(100dvh - 32px));
  padding: 14px;
  border: 1px solid #40505b;
  border-radius: 10px;
  background: #11181c;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.55);
  transform: translate(-50%, -50%);
}

.import-tray[hidden] {
  display: none;
}

.import-tray label {
  margin: 0;
  color: #e9f3f6;
  font-size: 0.98rem;
  font-weight: 900;
}

.import-dialog {
  display: grid;
  gap: 10px;
}

.import-dialog-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.import-dialog-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.import-tray textarea {
  min-height: 290px;
  max-height: min(460px, 56dvh);
  margin-bottom: 0;
  resize: vertical;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.threat-search {
  flex-shrink: 0;
  margin-bottom: 10px;
}

.team-slots {
  display: grid;
  flex-shrink: 0;
  gap: 5px;
}

.slot-card {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 78px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11171b;
  text-align: left;
  color: var(--text);
}

.slot-card.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(63, 181, 138, 0.35);
}

.slot-card.empty {
  color: var(--muted);
}

.sprite-frame {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 7px;
  background: #20282d;
  overflow: hidden;
}

.sprite-frame img {
  max-width: 66px;
  max-height: 66px;
  image-rendering: auto;
}

.item-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 4px;
  background-image: url("itemicons-sheet.png");
  background-repeat: no-repeat;
  background-size: 256px auto;
  image-rendering: pixelated;
  vertical-align: -3px;
}

.slot-name,
.suggestion-name {
  display: block;
  color: var(--text);
  font-weight: 850;
}

.slot-meta,
.mini {
  color: var(--muted);
  font-size: 0.82rem;
}

.base-stats-line {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  color: #c6d4dd;
  font-size: 0.68rem;
  line-height: 1.25;
}

.slot-card .base-stats-line {
  gap: 4px;
  margin-top: 4px;
  font-size: 0.7rem;
}

.slot-card .base-stats-line span {
  padding: 2px 5px;
}

.base-stats-line span {
  display: inline-flex;
  gap: 3px;
  padding: 1px 5px;
  border: 1px solid rgba(52, 64, 73, 0.85);
  border-radius: 999px;
  background: #0f1518;
  white-space: nowrap;
}

.base-stats-line .base-stats-label {
  padding-left: 0;
  border-color: transparent;
  background: transparent;
  color: #a9bdc8;
  font-weight: 900;
}

.base-stats-line b {
  color: var(--muted);
}

.remove-slot {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
}

.summary-grid,
.stat-grid,
.coverage-grid {
  display: grid;
  gap: 8px;
}

.summary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: auto auto minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  margin-top: 8px;
  overflow: hidden;
  align-content: start;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 58px;
  padding: 8px;
  background: #11171b;
}

.metric strong {
  display: block;
  font-size: 0.98rem;
  line-height: 1.25;
}

.type-planner {
  grid-column: 1 / -1;
  min-height: 0;
  align-self: start;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px;
  background: #11171b;
}

.type-planner-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.78rem;
}

.type-planner-head strong {
  color: var(--text);
}

.type-planner-head span {
  display: inline-flex;
  gap: 5px;
  white-space: nowrap;
}

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

.type-balance-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 7px;
}

.type-balance-summary span {
  min-height: 34px;
  padding: 5px 7px;
  border: 1px solid rgba(52, 64, 73, 0.75);
  border-radius: 6px;
  background: #0f1518;
  color: #dce6eb;
  font-size: 0.72rem;
  line-height: 1.3;
}

.type-balance-summary b {
  color: var(--accent-2);
}

.type-balance-card {
  display: grid;
  grid-template-columns: minmax(64px, auto) 1fr;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 3px 5px;
  border: 1px solid rgba(52, 64, 73, 0.8);
  border-radius: 6px;
  background: #0f1518;
}

.type-balance-card.danger {
  border-color: rgba(231, 111, 100, 0.72);
  background: rgba(231, 111, 100, 0.08);
}

.type-balance-card.warn {
  border-color: rgba(230, 178, 74, 0.58);
}

.type-balance-card.safe {
  border-color: rgba(84, 201, 143, 0.42);
}

.type-balance-card.neutral {
  opacity: 0.74;
}

.type-balance-card .type-icon {
  min-width: 62px;
  height: 20px;
  padding-inline: 4px;
}

.balance-badges {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 3px;
}

.balance-badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #172025;
  color: #dce6eb;
  font-size: 0.62rem;
  font-weight: 900;
  white-space: nowrap;
}

.balance-badge.weak {
  background: rgba(231, 111, 100, 0.2);
  color: #ffd4cf;
}

.balance-badge.resist {
  background: rgba(84, 201, 143, 0.18);
  color: #d8f4e7;
}

.balance-badge.immune {
  background: rgba(100, 166, 232, 0.18);
  color: #d8ebff;
}

.balance-badge.neutral {
  color: var(--muted);
}

.type-tables {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  height: calc(100% - 24px);
  min-height: 0;
}

.type-table {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: #0f1518;
}

.type-table-weak {
  border-color: rgba(231, 111, 100, 0.4);
}

.type-table-title,
.type-table-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.type-table-title {
  padding: 6px 7px;
  border-bottom: 1px solid var(--line);
}

.type-table-title strong {
  color: #dce6eb;
  font-size: 0.82rem;
}

.type-table-title span {
  display: none;
}

.type-table-rows {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-content: start;
  overflow: hidden;
  padding: 7px;
}

.type-table-row {
  min-height: 23px;
  padding: 2px 5px 2px 2px;
  border: 1px solid rgba(52, 64, 73, 0.75);
  border-radius: 6px;
  background: #11191d;
}

.type-table-row strong {
  color: #dce6eb;
  font-size: 0.68rem;
  text-align: left;
  white-space: nowrap;
}

.type-icon-row,
.weakness-icons {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  vertical-align: middle;
}

.type-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  height: 19px;
  padding: 1px 5px;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
  color: #081014;
  font-size: 0.63rem;
  font-weight: 950;
  justify-self: start;
  width: fit-content;
}

.type-table-row .type-icon {
  min-width: 66px;
  height: 20px;
  padding-inline: 5px;
}

.type-table-more {
  min-width: 64px;
  justify-content: center;
  padding-inline: 8px;
  border-style: dashed;
  color: var(--muted);
}

.type-icon-row .type-icon {
  min-width: 0;
  height: 18px;
  padding-inline: 4px;
}

.type-name,
.type-count {
  color: #081014;
}

.type-name {
  max-width: 66px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-count {
  display: inline-grid;
  place-items: center;
  min-width: 15px;
  height: 15px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  font-size: 0.6rem;
}

.empty-note {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.8;
}

.editor-empty {
  display: grid;
  place-items: center;
  min-height: 420px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.editor-empty.compact {
  min-height: 180px;
  padding: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.select-with-art {
  position: relative;
}

.select-with-art :is(select, input).has-art {
  min-height: 50px;
  padding-left: 60px;
}

.combo-input {
  min-width: 0;
  padding-right: 42px;
}

.combo-picker {
  position: relative;
  width: 100%;
}

.combo-picker:focus-within {
  z-index: 30;
}

.combo-toggle {
  position: absolute;
  top: 50%;
  right: 9px;
  display: grid;
  place-items: center;
  width: 24px;
  min-width: 0;
  height: 24px;
  min-height: 0;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #a8c0cc;
}

.combo-toggle:hover {
  background: rgba(75, 194, 146, 0.08);
  filter: none;
}

.combo-toggle::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: -3px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.combo-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 12000;
  display: grid;
  gap: 4px;
  max-height: min(330px, 46vh);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid #44515c;
  border-radius: 8px;
  background: #0d1418;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.42);
}

.combo-menu[hidden] {
  display: none;
}

.combo-option {
  justify-content: flex-start;
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-left-width: 5px;
  border-radius: 6px;
  background: #111a1f;
  color: #edf7fa;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 800;
}

.combo-option:hover,
.combo-option:focus-visible {
  border-color: rgba(75, 194, 146, 0.55);
  background: #172229;
  filter: none;
}

.combo-option[hidden],
.combo-empty[hidden] {
  display: none;
}

.combo-empty {
  padding: 9px 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.select-art {
  position: absolute;
  left: 9px;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  transform: translateY(-50%);
  border-radius: 6px;
  background: #20282d;
  pointer-events: none;
}

.select-art img {
  max-width: 52px;
  max-height: 52px;
}

.select-art.pokemon-art img {
  transform: translateX(-3px);
}

.select-art .item-icon {
  margin: 0;
  transform: scale(1.45);
  transform-origin: center;
}

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

.sp-editor input {
  text-align: center;
  padding-inline: 5px;
}

.stat-planner {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.02);
}

.stat-planner-head,
.stat-planner-row {
  display: grid;
  grid-template-columns: 62px 42px minmax(90px, 1fr) 92px 48px;
  align-items: center;
  gap: 8px;
}

.stat-planner-head {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.stat-planner-row {
  min-height: 32px;
}

.stat-label {
  color: #dce6eb;
  font-size: 0.82rem;
  font-weight: 900;
}

.base-number,
.final-stat {
  font-size: 0.94rem;
}

.base-line {
  margin: 0;
}

.points-cell {
  display: grid;
  grid-template-columns: 1fr 18px;
  align-items: center;
  gap: 5px;
}

.points-cell input {
  min-height: 28px;
  padding: 4px 6px;
  text-align: center;
}

.iv-box {
  display: grid;
  place-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #151d22;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.nature-arrow {
  min-width: 18px;
  text-align: center;
  font-size: 0.92rem;
  font-weight: 900;
  line-height: 1;
}

.nature-arrow.up { color: #54c98f; }
.nature-arrow.down { color: #e76f64; }

.sp-total {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.sp-total.bad {
  color: var(--danger);
}

.spread-recs {
  display: grid;
  grid-template-rows: auto;
  gap: 7px;
  margin-top: 10px;
  max-height: 268px;
  border: 1px solid rgba(52, 64, 73, 0.9);
  border-radius: 8px;
  background: rgba(15, 21, 24, 0.72);
  overflow: hidden;
}

.spread-recs-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 0;
  max-height: 226px;
  overflow-y: auto;
  padding: 0 7px 7px;
}

.spread-recs-list::-webkit-scrollbar {
  width: 8px;
}

.spread-recs-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #3a4650;
}

.spread-recs-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 9px 34px 9px 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  list-style: none;
  position: relative;
}

.spread-recs-head strong {
  color: #e8f2f5;
  font-size: 0.86rem;
}

.spread-recs-head::-webkit-details-marker {
  display: none;
}

.spread-recs-head::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid #9fb5c0;
  border-bottom: 2px solid #9fb5c0;
  transform: translateY(-65%) rotate(45deg);
  transition: transform 0.15s ease;
}

.spread-recs[open] .spread-recs-head {
  border-bottom: 1px solid rgba(52, 64, 73, 0.75);
}

.spread-recs[open] .spread-recs-head::after {
  transform: translateY(-35%) rotate(225deg);
}

.spread-rec {
  display: grid;
  gap: 4px;
  width: 100%;
  flex: 0 0 auto;
  min-height: 66px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #10181d;
  color: #f4fbfd;
  text-align: left;
  cursor: pointer;
}

.spread-rec:hover {
  border-color: rgba(75, 194, 146, 0.75);
  background: #12211e;
}

.spread-title {
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1.2;
}

.spread-finals {
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.35;
}

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

.move-select {
  border-left-width: 8px;
  font-weight: 800;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.move-select option {
  background: #10161a;
  color: #e8f2f5;
}

.move-select option:checked {
  background: #1b272e;
  color: #ffffff;
}

.move-type-empty { border-left-color: var(--line); }
.move-type-Normal { border-left-color: #b4b0a5; background: linear-gradient(90deg, rgba(180, 176, 165, 0.16), #0f1418 38%); }
.move-type-Fire { border-left-color: #f28c58; background: linear-gradient(90deg, rgba(242, 140, 88, 0.2), #0f1418 38%); }
.move-type-Water { border-left-color: #64a6e8; background: linear-gradient(90deg, rgba(100, 166, 232, 0.2), #0f1418 38%); }
.move-type-Electric { border-left-color: #f2cf52; background: linear-gradient(90deg, rgba(242, 207, 82, 0.2), #0f1418 38%); }
.move-type-Grass { border-left-color: #6fca72; background: linear-gradient(90deg, rgba(111, 202, 114, 0.2), #0f1418 38%); }
.move-type-Ice { border-left-color: #92d5d8; background: linear-gradient(90deg, rgba(146, 213, 216, 0.2), #0f1418 38%); }
.move-type-Fighting { border-left-color: #cf6b64; background: linear-gradient(90deg, rgba(207, 107, 100, 0.2), #0f1418 38%); }
.move-type-Poison { border-left-color: #b882d7; background: linear-gradient(90deg, rgba(184, 130, 215, 0.2), #0f1418 38%); }
.move-type-Ground { border-left-color: #d6b06d; background: linear-gradient(90deg, rgba(214, 176, 109, 0.2), #0f1418 38%); }
.move-type-Flying { border-left-color: #95b4e8; background: linear-gradient(90deg, rgba(149, 180, 232, 0.2), #0f1418 38%); }
.move-type-Psychic { border-left-color: #ef7da2; background: linear-gradient(90deg, rgba(239, 125, 162, 0.2), #0f1418 38%); }
.move-type-Bug { border-left-color: #a7bf4f; background: linear-gradient(90deg, rgba(167, 191, 79, 0.2), #0f1418 38%); }
.move-type-Rock { border-left-color: #bca967; background: linear-gradient(90deg, rgba(188, 169, 103, 0.2), #0f1418 38%); }
.move-type-Ghost { border-left-color: #7f79bc; background: linear-gradient(90deg, rgba(127, 121, 188, 0.22), #0f1418 38%); }
.move-type-Dragon { border-left-color: #7b70e8; background: linear-gradient(90deg, rgba(123, 112, 232, 0.22), #0f1418 38%); }
.move-type-Dark { border-left-color: #8b746b; background: linear-gradient(90deg, rgba(139, 116, 107, 0.22), #0f1418 38%); }
.move-type-Steel { border-left-color: #a8b8c6; background: linear-gradient(90deg, rgba(168, 184, 198, 0.2), #0f1418 38%); }
.move-type-Fairy { border-left-color: #e5a1d9; background: linear-gradient(90deg, rgba(229, 161, 217, 0.2), #0f1418 38%); }

.stat-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-top: 12px;
}

.stat-box {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: #10161a;
}

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

.stat-head span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.stat-head strong {
  font-size: 1.18rem;
}

.stat-bar {
  height: 7px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #263039;
}

.stat-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.stat-low { background: #d85f5b; }
.stat-mid { background: #e6b24a; }
.stat-high { background: #54c98f; }

.strategy-box {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #11171b;
  color: #dce6eb;
}

.suggestions,
.counters {
  display: grid;
  gap: 10px;
}

.suggestion-card,
.counter-card {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #11171b;
}

.threat-panel .counter-card,
.counters-panel .counter-card {
  grid-template-columns: 46px 1fr;
  gap: 8px;
  padding: 8px;
}

.threat-panel .sprite-frame,
.counters-panel .sprite-frame {
  width: 46px;
  height: 46px;
}

.threat-panel .sprite-frame img,
.counters-panel .sprite-frame img {
  max-width: 52px;
  max-height: 52px;
}

.threat-panel .suggestion-explain,
.counters-panel .suggestion-explain {
  font-size: 0.78rem;
  line-height: 1.3;
}

.threat-panel .tag-row,
.counters-panel .tag-row {
  gap: 4px;
  margin-top: 5px;
}

.threat-panel .tag,
.counters-panel .tag {
  min-height: 22px;
  padding-inline: 7px;
  font-size: 0.72rem;
}

.threat-panel .mini,
.counters-panel .mini {
  font-size: 0.76rem;
}

.threat-panel .base-stats-line,
.counters-panel .base-stats-line {
  gap: 3px;
  font-size: 0.62rem;
}

.threat-panel .base-stats-line span,
.counters-panel .base-stats-line span {
  padding-inline: 4px;
}

.suggestion-explain {
  margin: 5px 0 0;
  color: #d5e1e7;
  font-size: 0.84rem;
  line-height: 1.35;
}

.insight-list {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.insight-line {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 8px;
  align-items: start;
  border: 1px solid rgba(52, 64, 73, 0.72);
  border-radius: 7px;
  padding: 6px 8px;
  background: rgba(15, 21, 24, 0.72);
}

.insight-line span {
  color: #7fd3b2;
  font-size: 0.72rem;
  font-weight: 900;
}

.insight-line p {
  margin: 0;
  color: #dce8ed;
  font-size: 0.78rem;
  line-height: 1.28;
}

.insight-line.warn {
  border-color: rgba(231, 111, 100, 0.42);
  background: rgba(50, 24, 23, 0.35);
}

.insight-line.warn span {
  color: #f0a29b;
}

.threat-panel .insight-line,
.counters-panel .insight-line {
  grid-template-columns: 66px 1fr;
  gap: 6px;
  padding: 5px 7px;
}

.threat-panel .insight-line p,
.counters-panel .insight-line p {
  font-size: 0.73rem;
}

.threat-target {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 58px 1fr;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #10161a;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.22);
}

.threat-target strong {
  display: block;
}

.suggestion-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
}

.suggestion-more {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(52, 64, 73, 0.65);
  margin-top: 10px;
}

.score {
  color: var(--accent-2);
  font-weight: 900;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.suggestion-card .tag {
  min-height: 23px;
  border-color: rgba(83, 145, 170, 0.55);
  background: #13212a;
  color: #cfe7f1;
  font-size: 0.72rem;
}

.suggestion-card .tag:nth-child(2n) {
  border-color: rgba(86, 176, 136, 0.5);
  background: #12231e;
  color: #d6f0e6;
}

.type-pill {
  min-height: 22px;
  padding-inline: 8px;
  color: #081014;
  border: 0;
}

.type-Fire { background: #f28c58; }
.type-Water { background: #64a6e8; }
.type-Grass { background: #6fca72; }
.type-Electric { background: #f2cf52; }
.type-Ice { background: #92d5d8; }
.type-Fighting { background: #cf6b64; }
.type-Poison { background: #b882d7; }
.type-Ground { background: #d6b06d; }
.type-Flying { background: #95b4e8; }
.type-Psychic { background: #ef7da2; }
.type-Bug { background: #a7bf4f; }
.type-Rock { background: #bca967; }
.type-Ghost { background: #7f79bc; }
.type-Dragon { background: #7b70e8; }
.type-Dark { background: #8b746b; color: #fff; }
.type-Steel { background: #a8b8c6; }
.type-Fairy { background: #e5a1d9; }
.type-Normal { background: #b4b0a5; }

.type-Ghost .type-name,
.type-Ghost .type-count,
.type-Dragon .type-name,
.type-Dragon .type-count,
.type-Dark .type-name,
.type-Dark .type-count {
  color: #fff;
}

.type-Ghost .type-count,
.type-Dragon .type-count,
.type-Dark .type-count {
  background: rgba(0, 0, 0, 0.28);
}

.warning {
  color: var(--danger);
  font-weight: 800;
}

@media (max-width: 1480px) {
  body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-shell {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: none;
    grid-template-areas:
      "team suggestions"
      "editor editor"
      "counters threat";
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .team-panel,
  .editor-panel,
  .suggestions-panel,
  .threat-panel,
  .counters-panel,
  .editor-panel #editor {
    overflow: visible;
  }

  .summary-grid {
    flex: none;
    overflow: visible;
  }

  .suggestions-panel .suggestions,
  .threat-panel .counters,
  .counters-panel .counters {
    max-height: min(640px, 72dvh);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 1180px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    height: auto;
    min-height: 86px;
    gap: 10px;
    padding: 10px 14px;
  }

  .brand-logo {
    width: min(290px, 68vw);
    max-height: 62px;
  }

  .rules {
    width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }

  .rules::-webkit-scrollbar {
    height: 6px;
  }

  .rules::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: #3a4650;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-template-areas:
      "team"
      "editor"
      "counters"
      "threat"
      "suggestions";
    height: auto;
    min-height: 0;
    overflow: visible;
    padding: 10px;
    gap: 12px;
  }

  .panel {
    min-height: 0;
    padding: 10px;
  }

  .team-panel,
  .editor-panel,
  .suggestions-panel,
  .threat-panel,
  .counters-panel,
  .editor-panel #editor {
    overflow: visible;
  }

  .suggestions-panel .suggestions,
  .threat-panel .counters,
  .counters-panel .counters {
    max-height: min(560px, 70dvh);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .site-footer {
    height: auto;
    min-height: 48px;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 10px 14px;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .site-footer span {
    overflow: visible;
    text-overflow: clip;
  }

  .form-grid,
  .moves-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    flex: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
    overflow: visible;
  }

  .type-planner {
    overflow: visible;
  }

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

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

  .stat-planner-head,
  .stat-planner-row {
    grid-template-columns: 44px 36px minmax(70px, 1fr) 76px 42px;
    gap: 5px;
  }

  .stat-planner {
    padding: 7px;
    overflow-x: auto;
  }

  .editor-empty {
    min-height: 220px;
  }

  .type-table-title,
  .type-table-row {
    grid-template-columns: 1fr;
  }

  .type-table-row .type-icon {
    min-width: 0;
  }

  .type-table-title span,
  .type-table-row strong {
    text-align: left;
  }
}

@media (max-width: 760px) {
  button,
  input,
  select,
  textarea {
    font-size: 0.98rem;
  }

  button,
  input,
  select {
    min-height: 44px;
  }

  .topbar {
    min-height: 78px;
    padding: 9px 10px;
  }

  .brand-logo {
    width: min(250px, 74vw);
    max-height: 54px;
  }

  .rules {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    overflow-x: visible;
    padding-bottom: 0;
  }

  .format-control {
    width: 100%;
    min-height: 34px;
  }

  .format-control:first-child {
    grid-column: 1 / -1;
  }

  .format-label {
    min-height: 34px;
    padding-inline: 10px;
  }

  .format-button {
    flex: 1;
    min-width: 0;
    min-height: 34px;
  }

  .language-control .format-button {
    min-width: 0;
  }

  .rules > span {
    justify-content: center;
    min-height: 34px;
    font-size: 0.75rem;
    text-align: center;
  }

  .app-shell {
    padding: 8px;
    gap: 10px;
  }

  .panel {
    border-radius: 7px;
    padding: 10px;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .section-head h2 {
    font-size: 1.02rem;
  }

  .section-head p {
    font-size: 0.9rem;
  }

  .team-actions,
  .import-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 7px;
  }

  .team-actions button,
  .import-actions button {
    width: 100%;
    min-height: 42px;
    padding-inline: 8px;
  }

  .import-tray {
    width: calc(100vw - 18px);
    max-height: calc(100dvh - 18px);
    padding: 10px;
  }

  .import-tray textarea {
    min-height: 260px;
    max-height: 58dvh;
  }

  .quick-add {
    grid-template-columns: 1fr;
  }

  .slot-card {
    grid-template-columns: 56px minmax(0, 1fr) 34px;
    gap: 8px;
    min-height: 76px;
    padding: 7px;
  }

  .sprite-frame {
    width: 56px;
    height: 56px;
  }

  .sprite-frame img {
    max-width: 64px;
    max-height: 64px;
  }

  .slot-name,
  .suggestion-name {
    font-size: 0.98rem;
  }

  .slot-meta,
  .mini {
    font-size: 0.78rem;
  }

  .slot-card .base-stats-line {
    font-size: 0.67rem;
  }

  .base-stats-line span {
    padding-inline: 4px;
  }

  .remove-slot {
    width: 34px;
    min-height: 34px;
  }

  .summary-grid {
    gap: 7px;
  }

  .metric {
    min-height: 54px;
    padding: 7px;
  }

  .metric strong {
    font-size: 0.9rem;
  }

  .type-planner-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .type-balance-summary {
    grid-template-columns: 1fr;
  }

  .type-balance-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .type-balance-card {
    grid-template-columns: minmax(58px, auto) 1fr;
    min-height: 30px;
  }

  .type-balance-card .type-icon {
    min-width: 58px;
  }

  .form-grid {
    gap: 10px;
  }

  .select-with-art :is(select, input).has-art {
    min-height: 56px;
    padding-left: 64px;
  }

  .select-art {
    width: 46px;
    height: 46px;
  }

  .select-art img {
    max-width: 58px;
    max-height: 58px;
  }

  .select-art.pokemon-art img {
    transform: none;
  }

  .select-art .item-icon {
    transform: scale(1.6);
  }

  .moves-grid {
    gap: 7px;
  }

  .move-select {
    min-height: 46px;
    border-left-width: 7px;
  }

  .spread-recs {
    max-height: 276px;
  }

  .spread-recs-list {
    max-height: 228px;
  }

  .spread-rec {
    min-height: 74px;
    padding: 10px;
  }

  .stat-planner-head,
  .stat-planner-row {
    grid-template-columns: 40px 34px minmax(80px, 1fr) 74px 42px;
    min-width: 0;
  }

  .points-cell input {
    min-height: 34px;
  }

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

  .suggestion-card,
  .counter-card,
  .threat-panel .counter-card,
  .counters-panel .counter-card {
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }

  .threat-panel .sprite-frame,
  .counters-panel .sprite-frame {
    width: 52px;
    height: 52px;
  }

  .threat-panel .sprite-frame img,
  .counters-panel .sprite-frame img {
    max-width: 60px;
    max-height: 60px;
  }

  .insight-line,
  .threat-panel .insight-line,
  .counters-panel .insight-line {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .suggestion-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .suggestion-actions button,
  .suggestion-more button {
    width: 100%;
  }

  .suggestion-more {
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: linear-gradient(180deg, rgba(23, 29, 33, 0.2), var(--panel) 28%);
    padding-bottom: 2px;
  }

  .threat-target {
    grid-template-columns: 52px 1fr;
  }
}

@media (max-width: 430px) {
  .brand-logo {
    width: min(220px, 78vw);
  }

  .format-button {
    min-width: 132px;
    padding-left: 10px;
  }

  .language-control .format-button {
    min-width: 88px;
  }

  .team-actions {
    grid-template-columns: 1fr 1fr;
  }

  .slot-card {
    grid-template-columns: 50px minmax(0, 1fr) 30px;
  }

  .sprite-frame {
    width: 50px;
    height: 50px;
  }

  .sprite-frame img {
    max-width: 58px;
    max-height: 58px;
  }

  .slot-card .base-stats-line span {
    padding: 1px 4px;
  }

  .type-balance-grid {
    grid-template-columns: 1fr;
  }

  .stat-planner-head {
    font-size: 0.66rem;
  }

  .stat-planner-head,
  .stat-planner-row {
    grid-template-columns: 34px 32px minmax(68px, 1fr) 62px 34px;
    gap: 4px;
  }

  .stat-label,
  .base-number,
  .final-stat {
    font-size: 0.8rem;
  }

  .points-cell {
    grid-template-columns: 1fr 14px;
    gap: 3px;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================
   Final responsive overrides
   Header, controls and dropdowns
   ========================= */

:root {
  --topbar-height: 78px;
  --footer-height: 26px;
}

/* Header base */

.topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  padding: 6px 16px;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  align-content: center;
  overflow: visible !important;
  position: relative;
  z-index: 1000;
}

.brand-block {
  display: flex;
  align-items: center;
  flex: 0 0 250px;
  min-width: 250px;
  height: 100%;
  overflow: hidden;
}

.topbar h1 {
  margin: 0;
  line-height: 0;
}

.brand-logo {
  display: block;
  width: 235px;
  height: auto;
  max-width: none;
  max-height: 62px;
  object-fit: contain;
  object-position: left center;
  flex-shrink: 0;
  transform: none;
}

/* Topbar controls */

.rules {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  max-width: 100%;
  gap: 6px;
  flex-wrap: wrap;
  overflow: visible !important;
  padding-bottom: 0;
  position: relative;
  z-index: 1001;
}

.rules > * {
  flex: 0 0 auto;
  width: auto !important;
  max-width: max-content;
}

.top-link,
.rules > span,
.format-control,
.language-control {
  flex: 0 0 auto;
  width: auto !important;
  max-width: max-content;
  white-space: nowrap;
}

.format-control {
  position: relative;
  z-index: 1002;
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: min(360px, calc(100vw - 24px));
  overflow: visible !important;
}

.format-control:first-child {
  grid-column: auto !important;
}

.format-label {
  flex: 0 0 auto;
  min-width: auto;
  white-space: nowrap;
}

.format-button {
  flex: 0 1 auto;
  width: auto !important;
  min-width: 0;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.language-control .format-button {
  min-width: 76px;
  max-width: 120px;
}

/* Dropdowns: importante para que vuelvan a desplegarse */

.format-menu {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 5000;
  min-width: 100%;
  max-width: min(340px, calc(100vw - 20px));
  overflow: visible;
}

.language-control .format-menu {
  min-width: 150px;
}

.format-menu[hidden] {
  display: none;
}

/* Shell/footer */

.app-shell {
  height: calc(100dvh - var(--topbar-height) - var(--footer-height));
}

.site-footer {
  height: var(--footer-height);
  min-height: var(--footer-height);
  padding: 0 10px;
  font-size: 0.64rem;
  line-height: 1;
}

/* Medium screens */

@media (max-width: 1480px) {
  body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-shell {
    height: auto;
    min-height: 0;
    overflow: visible;
  }
}

/* Tablet / narrow desktop */

@media (max-width: 1180px) {
  .topbar {
    height: auto;
    min-height: 104px;
    padding: 10px 12px;
    gap: 8px;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    overflow: visible !important;
  }

  .brand-block {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    height: 46px;
    justify-content: center;
    overflow: hidden;
  }

  .brand-logo {
    width: min(235px, 72vw);
    max-height: 46px;
  }

  .rules {
    width: 100%;
    max-width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    overflow: visible !important;
    padding-bottom: 0;
  }

  .format-button {
    max-width: 190px;
  }

  .language-control .format-button {
    max-width: 110px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-template-areas:
      "team"
      "editor"
      "counters"
      "threat"
      "suggestions";
    height: auto;
    min-height: 0;
    overflow: visible;
    padding: 10px;
    gap: 12px;
  }

  .site-footer {
    height: auto;
    min-height: var(--footer-height);
    justify-content: center;
    flex-wrap: wrap;
    white-space: normal;
    overflow: visible;
    text-align: center;
    padding: 6px 10px;
  }

  .site-footer span {
    overflow: visible;
    text-overflow: clip;
  }
}

/* Mobile */

@media (max-width: 760px) {
  .topbar {
    min-height: 96px;
    padding: 8px;
    overflow: visible !important;
  }

  .brand-block {
    height: 42px;
  }

  .brand-logo {
    width: min(210px, 72vw);
    max-height: 42px;
  }

  .rules {
    display: flex !important;
    grid-template-columns: none !important;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    overflow: visible !important;
    gap: 6px;
    padding-bottom: 0;
  }

  .rules > * {
    width: auto !important;
    max-width: max-content;
  }

  .top-link,
  .rules > span {
    min-height: 32px;
    padding-inline: 10px;
    font-size: 0.72rem;
  }

  .format-control,
  .language-control {
    width: auto !important;
    min-height: 32px;
    max-width: calc(100vw - 18px);
    overflow: visible !important;
  }

  .format-label {
    min-height: 32px;
    padding-inline: 9px;
    font-size: 0.72rem;
  }

  .format-button {
    width: auto !important;
    min-height: 32px;
    min-width: 0;
    max-width: 155px;
    padding: 0 30px 0 10px;
    font-size: 0.72rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .language-control .format-button {
    min-width: 70px;
    max-width: 100px;
  }

  .format-menu {
    left: 0;
    right: auto;
    min-width: max-content;
    max-width: calc(100vw - 20px);
  }

  .app-shell {
    padding: 8px;
    gap: 10px;
  }
}

/* Very small mobile */

@media (max-width: 430px) {
  .topbar {
    min-height: 92px;
  }

  .brand-block {
    height: 38px;
  }

  .brand-logo {
    width: min(185px, 70vw);
    max-height: 38px;
  }

  .rules {
    gap: 5px;
  }

  .top-link,
  .rules > span {
    min-height: 30px;
    padding-inline: 8px;
    font-size: 0.68rem;
  }

  .format-label {
    min-height: 30px;
    padding-inline: 8px;
    font-size: 0.68rem;
  }

  .format-button {
    min-height: 30px;
    max-width: 132px;
    padding-right: 28px;
    font-size: 0.68rem;
  }

  .language-control .format-button {
    min-width: 64px;
    max-width: 88px;
  }
}

/* =========================
   UX polish and mobile fixes
   ========================= */

.brand-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.top-link,
.format-control {
  box-shadow: inset 0 0 0 1px rgba(141, 181, 199, 0.03);
}

.format-control {
  border-color: rgba(63, 181, 138, 0.45);
  background: linear-gradient(180deg, #121a1f, #0f1519);
}

.format-label {
  color: #a8c0cb;
}

.rule-badge,
.rules > span {
  cursor: default;
  border-color: rgba(52, 64, 73, 0.72);
  background: #0e1418;
  color: #92a4af;
}

.coffee-link {
  border-color: rgba(230, 178, 74, 0.58);
  background: rgba(230, 178, 74, 0.12);
  color: #f5d486;
}

.coffee-link:hover,
.coffee-link:focus-visible {
  border-color: rgba(230, 178, 74, 0.9);
  background: rgba(230, 178, 74, 0.2);
}

.select-art.pokemon-art img {
  transform: none;
}

.about-card {
  overflow-wrap: anywhere;
}

.about-card a {
  word-break: break-word;
}

@media (max-height: 760px) and (min-width: 1181px) {
  body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-shell {
    height: auto;
    min-height: 760px;
    overflow: visible;
  }

  .team-panel,
  .editor-panel,
  .suggestions-panel,
  .threat-panel,
  .counters-panel,
  .editor-panel #editor {
    min-height: 0;
  }

  .suggestions-panel .suggestions,
  .threat-panel .counters,
  .counters-panel .counters {
    max-height: 560px;
    overflow-y: auto;
  }
}

@media (max-width: 760px) {
  .about-shell {
    width: min(100% - 18px, 720px);
    padding: 16px 0 24px;
  }

  .about-hero {
    margin-bottom: 12px;
    padding-bottom: 12px;
  }

  .about-hero h2 {
    font-size: clamp(1.45rem, 9vw, 2.1rem);
    line-height: 1.05;
  }

  .about-hero p,
  .about-card p {
    font-size: 0.94rem;
    line-height: 1.45;
  }

  .about-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .about-card {
    padding: 12px;
  }
}

@media (max-width: 430px) {
  .coffee-link {
    max-width: calc(100vw - 24px);
  }
}

/* =========================
   Header grouping and compact panels
   ========================= */

.rule-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 3px;
  border: 1px solid rgba(52, 64, 73, 0.9);
  border-radius: 999px;
  background: rgba(8, 13, 16, 0.8);
  box-shadow: inset 0 0 0 1px rgba(141, 181, 199, 0.03);
}

.rule-group .rule-badge,
.rule-group > span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 0;
  border-radius: 999px;
  padding: 0 8px;
  background: #121a1f;
  color: #a9bac4;
  font-size: 0.76rem;
  font-weight: 850;
  white-space: nowrap;
}

.coffee-link {
  order: 100;
}

@media (min-width: 1181px) {
  .coffee-link {
    margin-left: 2px;
  }
}

@media (max-width: 760px) {
  .rule-group {
    justify-content: center;
    flex-wrap: wrap;
    max-width: 100%;
    border-radius: 14px;
  }

  .rule-group .rule-badge,
  .rule-group > span {
    min-height: 26px;
    padding-inline: 8px;
    font-size: 0.72rem;
  }

  .team-panel {
    max-height: calc(100dvh - 112px);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .team-panel .section-head {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .team-panel .section-head h2 {
    white-space: nowrap;
  }

  .team-panel .team-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }

  .team-panel .team-actions button {
    min-width: 0;
    min-height: 38px;
    padding-inline: 6px;
    font-size: 0.82rem;
  }

  .team-panel .quick-add {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .team-panel .quick-add button {
    min-width: 78px;
    padding-inline: 10px;
  }

  .team-panel .slot-card {
    grid-template-columns: 54px minmax(0, 1fr) 30px;
    min-height: 72px;
  }

  .team-panel .slot-card > span:nth-child(2) {
    min-width: 0;
  }

  .team-panel .slot-meta,
  .team-panel .slot-name {
    overflow-wrap: anywhere;
  }

  .threat-panel .threat-target,
  .threat-panel .counter-card {
    grid-template-columns: 1fr;
  }

  .threat-panel .threat-target > .sprite-frame,
  .threat-panel .counter-card > .sprite-frame {
    display: none;
  }

  .threat-panel .counters {
    max-height: min(360px, 46dvh);
  }
}

@media (max-width: 460px) {
  .team-panel .team-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .team-panel .quick-add {
    grid-template-columns: 1fr;
  }
}

/* =========================
   Compact desktop/window breakpoints
   ========================= */

.threat-target-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.threat-target-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.threat-target-head .threat-usage {
  flex: 0 0 auto;
  margin-right: auto;
  font-weight: 850;
}

.threat-target-head .type-icon-row {
  flex: 0 0 auto;
}

@media (min-width: 1181px) {
  .team-panel .section-head,
  .editor-panel .section-head {
    align-items: center;
  }
}

@media (max-width: 1480px) and (min-width: 761px) {
  .app-shell {
    align-items: start;
  }

  .team-panel {
    max-height: calc(100dvh - var(--topbar-height) - var(--footer-height) - 28px);
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .team-panel::-webkit-scrollbar {
    width: 8px;
  }

  .team-panel::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: #3a4650;
  }

  .team-panel .section-head,
  .editor-panel .section-head {
    align-items: center;
  }

  .team-panel .team-actions {
    flex-wrap: nowrap;
  }

  .team-panel .team-actions button {
    min-width: 0;
    padding-inline: 9px;
  }

  .suggestions-panel {
    align-self: start;
    max-height: calc(100dvh - var(--topbar-height) - var(--footer-height) - 28px);
  }

  .suggestions-panel .suggestions {
    flex: 0 1 auto;
    max-height: min(520px, 62dvh);
  }

  .suggestion-more {
    margin-top: 0;
    padding-top: 8px;
    border-top: 1px solid rgba(52, 64, 73, 0.65);
  }
}

@media (max-width: 1180px) and (min-width: 761px) {
  .team-panel {
    max-height: min(760px, calc(100dvh - 142px));
  }

  .suggestions-panel {
    max-height: none;
  }

  .suggestions-panel .suggestions {
    max-height: min(520px, 64dvh);
  }
}

@media (max-width: 760px) {
  .section-head {
    gap: 6px;
  }

  .team-panel,
  .suggestions-panel,
  .threat-panel {
    max-width: 100%;
  }

  .suggestions-panel {
    align-self: stretch;
  }

  .suggestions-panel .suggestions {
    flex: 0 1 auto;
    max-height: min(500px, 64dvh);
  }

  .suggestion-more {
    margin-top: 0;
    padding-top: 7px;
    border-top: 1px solid rgba(52, 64, 73, 0.65);
  }

  .threat-target {
    padding: 8px;
  }

  .threat-target-head {
    justify-content: space-between;
    flex-wrap: nowrap;
  }
}

/* =========================
   Responsive polish: compact windows
   ========================= */

.team-panel,
.suggestions-panel,
.threat-panel {
  scrollbar-gutter: stable;
}

.team-panel::-webkit-scrollbar {
  width: 8px;
}

.team-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #3a4650;
}

.team-panel .section-head,
.editor-panel .section-head,
.suggestions-panel .section-head,
.threat-panel .section-head,
.counters-panel .section-head {
  align-items: center;
}

.team-panel .section-head h2 {
  white-space: nowrap;
}

.threat-target {
  grid-template-columns: 46px minmax(0, 1fr);
  padding: 8px;
}

.threat-target .sprite-frame {
  width: 46px;
  height: 46px;
}

.threat-target .base-stats-line {
  margin-top: 5px;
}

@media (max-width: 1480px) and (min-width: 761px) {
  .app-shell {
    align-items: start;
  }

  .team-panel {
    align-self: start;
    height: auto;
    max-height: min(820px, calc(100dvh - 148px));
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .suggestions-panel {
    align-self: start;
    height: fit-content;
    max-height: none;
  }

  .suggestions-panel .suggestions {
    flex: 0 1 auto !important;
    max-height: min(470px, calc(100dvh - 250px));
    overflow-y: auto;
  }

  .suggestion-more {
    flex: 0 0 auto;
    margin-top: 8px;
    padding-top: 8px;
    background: var(--panel);
  }
}

@media (max-width: 1180px) and (min-width: 761px) {
  .team-panel {
    max-height: min(760px, calc(100dvh - 150px));
  }

  .suggestions-panel .suggestions {
    max-height: min(430px, calc(100dvh - 238px));
  }

  .team-panel .team-actions {
    justify-content: flex-end;
  }
}

@media (max-width: 760px) {
  .team-panel {
    max-height: min(780px, calc(100dvh - 126px));
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .suggestions-panel {
    height: fit-content;
  }

  .suggestions-panel .suggestions {
    flex: 0 1 auto !important;
    max-height: min(420px, calc(100dvh - 210px));
  }

  .threat-target {
    grid-template-columns: 1fr;
    padding: 8px 10px;
  }

  .threat-target .base-stats-line {
    gap: 3px;
  }

  .threat-target .base-stats-line span {
    padding: 1px 4px;
    font-size: 0.6rem;
  }

  .threat-panel .counter-card {
    padding: 8px;
  }

  .threat-panel .suggestion-explain {
    font-size: 0.78rem;
    line-height: 1.28;
  }
}

/* =========================
   Final panel/footer fit
   ========================= */

:root {
  --footer-height: 48px;
}

body {
  height: 100dvh;
  overflow: hidden;
}

.app-shell {
  height: calc(100dvh - var(--topbar-height) - var(--footer-height));
  overflow: hidden;
}

.team-panel {
  max-height: 100%;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

.site-footer {
  height: var(--footer-height);
  min-height: var(--footer-height);
  align-content: center;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px 8px;
  padding: 5px 10px;
  white-space: normal;
  overflow: hidden;
  text-align: center;
  line-height: 1.22;
}

.site-footer span {
  overflow: visible;
  text-overflow: clip;
}

@media (max-width: 1480px) {
  body {
    height: 100dvh;
    overflow: hidden;
  }

  .app-shell {
    height: calc(100dvh - var(--topbar-height) - var(--footer-height));
    overflow: hidden;
  }

  .team-panel {
    max-height: 100%;
  }
}

@media (max-height: 760px) and (min-width: 1181px) {
  body {
    height: 100dvh;
    overflow: hidden;
  }

  .app-shell {
    height: calc(100dvh - var(--topbar-height) - var(--footer-height));
    min-height: 0;
    overflow: hidden;
  }

  .team-panel {
    max-height: 100%;
  }
}

@media (max-width: 760px) {
  :root {
    --footer-height: 66px;
  }

  .app-shell {
    height: calc(100dvh - var(--topbar-height) - var(--footer-height));
    overflow: hidden;
  }

  .team-panel {
    max-height: 100%;
  }

  .site-footer {
    font-size: 0.58rem;
    gap: 1px 6px;
    padding: 5px 8px;
  }
}

@media (max-width: 1180px) {
  body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-shell {
    height: auto;
    overflow: visible;
  }

  .team-panel {
    max-height: min(780px, calc(100dvh - 150px));
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }
}

@media (max-width: 760px) {
  .team-panel {
    max-height: min(720px, calc(100dvh - 154px));
  }
}

/* =========================
   Panel heading alignment
   ========================= */

.panel {
  padding-top: 9px;
}

.section-head {
  margin-bottom: 8px;
}

.section-head h2 {
  margin: 0;
  line-height: 1.12;
}

.section-head p {
  margin-top: 4px;
}

@media (max-width: 760px) {
  .panel {
    padding-top: 8px;
  }

  .section-head {
    margin-bottom: 7px;
  }
}

/* =========================
   Suggestions height fill
   ========================= */

@media (min-width: 1181px) {
  .suggestions-panel {
    align-self: stretch !important;
    height: auto !important;
    max-height: 100% !important;
    min-height: 0;
  }

  .suggestions-panel .suggestions {
    flex: 1 1 auto !important;
    min-height: 0;
    max-height: none !important;
  }

  .suggestion-more {
    flex: 0 0 auto;
  }
}

@media (max-width: 1480px) and (min-width: 1181px) {
  .app-shell {
    align-items: stretch;
  }
}

/* =========================
   Team panel scroll and type table fit
   ========================= */

.type-planner,
.type-table,
.type-table-rows {
  overflow: visible;
}

.type-tables {
  height: auto;
}

@media (min-width: 1181px) {
  .team-panel {
    align-self: stretch !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0;
    padding-bottom: 14px;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }
}

.team-panel .summary-grid {
  flex: 0 0 auto;
  grid-template-rows: auto auto auto;
  overflow: visible;
  padding-bottom: 2px;
}

.team-panel .type-planner {
  align-self: stretch;
}

.team-full-button:disabled {
  opacity: 1;
  background: #2b775f;
  color: #07110d;
  font-weight: 800;
  line-height: 1;
  text-shadow: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* =========================
   Footer compact fit
   ========================= */

:root {
  --footer-height: 34px;
}

.site-footer {
  gap: 1px 7px;
  padding: 3px 10px;
  font-size: 0.58rem;
  line-height: 1.12;
}

@media (max-width: 1180px) {
  :root {
    --footer-height: 48px;
  }

  .site-footer {
    font-size: 0.56rem;
    line-height: 1.15;
    padding: 4px 8px;
  }
}

@media (max-width: 760px) {
  :root {
    --footer-height: 58px;
  }
}

/* =========================
   Three-column tabbed workspace
   ========================= */

:root {
  --topbar-height: 88px;
}

.topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  padding-block: 8px;
}

.brand-block {
  flex: 0 0 330px;
  min-width: 300px;
  justify-content: center;
}

.brand-logo {
  width: min(315px, 100%);
  max-height: 78px;
}

.app-shell {
  grid-template-columns: minmax(300px, 0.9fr) minmax(360px, 1.02fr) minmax(420px, 1.32fr);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "team editor side";
  align-items: stretch;
}

.side-panel {
  grid-area: side;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.side-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  flex: 0 0 auto;
  margin-bottom: 9px;
  border: 1px solid rgba(52, 64, 73, 0.78);
  border-radius: 9px;
  padding: 4px;
  background: #10161a;
}

.side-tab {
  min-width: 0;
  min-height: 34px;
  padding: 0 9px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-tab.active {
  border-color: rgba(63, 181, 138, 0.55);
  background: rgba(63, 181, 138, 0.18);
  color: #e6fff4;
}

.side-tab-panel {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.side-tab-panel[hidden] {
  display: none !important;
}

.side-tab-panel .suggestions,
.side-tab-panel .counters {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.threat-tools {
  display: flex;
  align-items: end;
  gap: 8px;
  margin: 8px 0;
  padding: 8px;
  border: 1px solid rgba(52, 64, 73, 0.72);
  border-radius: 8px;
  background: #10161a;
}

.threat-advanced-toggle.active {
  border-color: rgba(230, 178, 74, 0.7);
  background: rgba(230, 178, 74, 0.18);
  color: #ffe0a0;
}

.threat-set-picker {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.threat-set-picker span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.threat-set-picker select {
  min-height: 34px;
  padding-block: 6px;
}

.threat-set-summary {
  display: block;
  margin-top: 3px;
}

.threat-final-stats {
  display: block;
  margin-top: 2px;
  color: #cfe1eb;
}

.threat-target .threat-tools,
.counter-card .threat-tools {
  margin: 8px 0 0;
}

.counter-threat-tools {
  padding: 6px;
}

.counter-threat-tools .threat-advanced-toggle {
  min-height: 30px;
  padding-inline: 10px;
}

.counter-threat-tools .threat-set-picker select {
  min-height: 30px;
  font-size: 0.78rem;
}

@media (min-width: 1600px) {
  .suggestions-panel .suggestions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
  }

  .suggestions-panel .strategy-box,
  .suggestions-panel .editor-empty {
    grid-column: 1 / -1;
  }

  .suggestions-panel .suggestion-card {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 8px;
  }

  .suggestions-panel .sprite-frame {
    width: 48px;
    height: 48px;
  }
}

/* =========================
   Type analysis compact fit
   ========================= */

.team-panel .type-balance-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.type-balance-card {
  min-width: 0;
  grid-template-columns: minmax(62px, 0.78fr) minmax(0, 1fr);
  overflow: hidden;
}

.type-balance-card .type-icon {
  width: 100%;
  min-width: 0;
  max-width: 94px;
}

.balance-badges {
  min-width: 0;
  overflow: hidden;
}

.balance-badge {
  min-width: 0;
}

@media (max-width: 1500px) {
  .type-balance-card {
    grid-template-columns: minmax(56px, 0.72fr) minmax(0, 1fr);
  }

  .type-balance-card .type-icon {
    max-width: 82px;
  }

  .balance-badge {
    padding-inline: 4px;
  }
}

@media (max-width: 1180px) {
  .topbar {
    min-height: 112px;
  }

  .brand-block {
    flex-basis: auto;
    min-width: 0;
    height: 54px;
  }

  .brand-logo {
    width: min(290px, 82vw);
    max-height: 58px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "team"
      "editor"
      "side";
  }

  .side-panel {
    min-height: min(720px, 82dvh);
  }
}

@media (max-width: 760px) {
  .side-tabs {
    grid-template-columns: 1fr;
  }

  .side-tab {
    min-height: 38px;
  }

  .threat-tools {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .team-panel .type-balance-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================
   Responsive system refresh
   ========================= */

:root {
  --topbar-height: 96px;
  --footer-height: 34px;
}

html,
body {
  width: 100%;
  max-width: 100%;
}

body {
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  display: grid !important;
  grid-template-columns: minmax(290px, 400px) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  height: var(--topbar-height) !important;
  min-height: var(--topbar-height) !important;
  padding: 6px clamp(12px, 1.8vw, 24px) !important;
}

.brand-block {
  width: 100%;
  min-width: 0 !important;
  height: 100% !important;
  justify-content: center !important;
  overflow: visible !important;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  height: 100%;
  max-width: 100%;
}

.brand-logo {
  width: clamp(270px, 19vw, 370px) !important;
  max-width: 100% !important;
  max-height: 88px !important;
  object-fit: contain;
  object-position: center center;
}

.rules {
  display: flex !important;
  align-items: center;
  justify-content: flex-end !important;
  gap: 6px !important;
  min-width: 0;
  overflow: visible !important;
}

.rules > *,
.rule-group > * {
  min-width: 0;
}

.format-control,
.top-link,
.rule-group {
  flex: 0 0 auto;
}

.format-button {
  max-width: min(235px, 28vw);
}

.app-shell {
  height: calc(100dvh - var(--topbar-height) - var(--footer-height)) !important;
  grid-template-columns: minmax(300px, 0.9fr) minmax(360px, 1.02fr) minmax(430px, 1.34fr);
  grid-template-areas: "team editor side";
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch !important;
  gap: 14px;
  overflow: hidden !important;
  padding: 10px clamp(12px, 1.6vw, 28px);
}

.panel,
.team-panel,
.editor-panel,
.side-panel {
  min-width: 0;
  min-height: 0;
}

.team-panel,
.editor-panel,
.side-panel {
  height: 100% !important;
  max-height: 100% !important;
}

.team-panel,
.editor-panel #editor,
.side-tab-panel .suggestions,
.side-tab-panel .counters {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  scrollbar-gutter: stable;
}

.rules::-webkit-scrollbar,
.side-tabs::-webkit-scrollbar {
  height: 0;
}

.rules,
.side-tabs {
  -ms-overflow-style: none;
}

.rules {
  scrollbar-width: none;
}

.team-panel .section-head {
  display: grid;
  grid-template-columns: minmax(126px, 0.34fr) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.team-panel .team-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.team-panel .team-actions button {
  min-width: 0;
  padding-inline: 5px;
  white-space: nowrap;
}

.side-panel {
  overflow: hidden !important;
}

.side-tabs {
  grid-template-columns: repeat(3, minmax(112px, 1fr)) !important;
  overflow: visible;
}

.side-tab-panel {
  min-height: 0;
}

.suggestion-more {
  flex: 0 0 auto;
}

.site-footer {
  height: var(--footer-height) !important;
  min-height: var(--footer-height) !important;
  padding: 3px 10px;
  overflow: hidden;
}

@media (min-width: 1800px) {
  .suggestions-panel .suggestions {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 1799px) {
  .suggestions-panel .suggestions {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 1700px) {
  .team-panel .section-head {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1280px) and (min-width: 901px) {
  :root {
    --topbar-height: 84px;
  }

  body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .topbar {
    grid-template-columns: minmax(220px, 285px) minmax(0, 1fr);
    height: auto !important;
    min-height: var(--topbar-height) !important;
    padding-block: 5px !important;
  }

  .brand-logo {
    width: clamp(215px, 22vw, 275px) !important;
    max-height: 72px !important;
  }

  .rules {
    justify-content: flex-end !important;
    flex-wrap: wrap !important;
    align-content: center;
  }

  .format-button {
    max-width: 190px;
  }

  .app-shell {
    height: auto !important;
    min-height: 0;
    grid-template-columns: minmax(310px, 0.92fr) minmax(420px, 1.08fr);
    grid-template-areas:
      "team editor"
      "side side";
    grid-template-rows: auto minmax(430px, 68dvh);
    align-items: start !important;
    overflow: visible !important;
    padding: 10px 12px;
  }

  .team-panel,
  .editor-panel,
  .side-panel {
    height: auto !important;
    max-height: none !important;
  }

  .team-panel,
  .editor-panel {
    max-height: calc(100dvh - var(--topbar-height) - var(--footer-height) - 28px) !important;
    overflow-y: auto !important;
  }

  .side-panel {
    height: min(680px, 78dvh) !important;
  }
}

@media (max-width: 900px) {
  :root {
    --topbar-height: 66px;
    --footer-height: 46px;
  }

  body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .topbar {
    grid-template-columns: minmax(132px, 170px) minmax(0, 1fr);
    height: auto !important;
    min-height: var(--topbar-height) !important;
    gap: 8px;
    padding: 6px 10px !important;
  }

  .brand-block {
    height: 52px !important;
    align-self: center;
  }

  .brand-logo {
    width: clamp(136px, 23vw, 170px) !important;
    max-height: 50px !important;
  }

  .rules {
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 2px 2px 5px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .rules > * {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  .top-link,
  .format-label,
  .format-button,
  .rule-group .rule-badge,
  .rule-group > span {
    min-height: 28px;
    font-size: 0.72rem;
  }

  .format-button {
    max-width: 160px;
    padding-right: 28px;
  }

  .rule-group {
    flex-wrap: nowrap !important;
    border-radius: 999px !important;
  }

  .app-shell {
    height: auto !important;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "team"
      "editor"
      "side";
    grid-template-rows: auto;
    overflow: visible !important;
    padding: 8px;
    gap: 10px;
  }

  .team-panel,
  .editor-panel,
  .side-panel {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .team-panel {
    max-height: min(820px, calc(100dvh - var(--topbar-height) - 18px)) !important;
    overflow-y: auto !important;
  }

  .editor-panel #editor {
    max-height: none !important;
    overflow: visible !important;
  }

  .side-panel {
    height: min(680px, 78dvh) !important;
    min-height: 440px;
    overflow: hidden !important;
  }

  .side-tabs {
    grid-template-columns: repeat(3, minmax(126px, 1fr)) !important;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .side-tab {
    min-height: 32px;
    font-size: 0.78rem;
  }

  .team-panel .section-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .team-panel .team-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }

  .team-panel .team-actions button {
    min-width: 0;
    padding-inline: 6px;
  }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr;
    height: auto !important;
    min-height: 0 !important;
    gap: 4px;
    padding-bottom: 8px !important;
  }

  .brand-block {
    height: 58px !important;
    justify-content: center !important;
  }

  .brand-link {
    width: min(300px, 82vw);
    height: 58px;
    max-height: 58px;
  }

  .rules {
    grid-column: 1;
    width: 100%;
    justify-content: center !important;
    flex-wrap: wrap !important;
    overflow: visible !important;
    padding-bottom: 0;
  }
}

@media (max-width: 620px) {
  :root {
    --topbar-height: 88px;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 4px;
    padding-top: 5px !important;
  }

  .brand-block {
    height: 44px !important;
    justify-content: center !important;
  }

  .brand-logo {
    width: min(238px, 78vw) !important;
    max-height: 44px !important;
  }

  .rules {
    grid-column: 1;
    width: 100%;
    justify-content: flex-start !important;
  }

  .team-panel .section-head {
    grid-template-columns: 1fr;
  }

  .quick-add {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

@media (max-width: 460px) {
  :root {
    --topbar-height: 92px;
    --footer-height: 54px;
  }

  .brand-logo {
    width: min(216px, 78vw) !important;
  }

  .team-panel .team-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-add {
    grid-template-columns: 1fr;
  }

  .slot-card {
    grid-template-columns: 50px minmax(0, 1fr) 28px;
  }

  .type-balance-grid,
  .team-panel .type-balance-grid {
    grid-template-columns: 1fr !important;
  }

  .site-footer {
    font-size: 0.52rem;
    line-height: 1.14;
  }
}

/* =========================
   Advanced counter calculator
   ========================= */

.threat-tools,
.counter-card .threat-tools,
.threat-target .threat-tools {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: start;
  gap: 7px;
  width: 100%;
  margin: 7px 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.threat-advanced-toggle {
  justify-self: start;
  min-height: 30px;
  padding-inline: 11px;
  border-color: rgba(141, 181, 199, 0.36);
  background: #11171b;
  color: #e7f0f4;
}

.threat-advanced-toggle.active {
  border-color: rgba(230, 178, 74, 0.78);
  background: rgba(230, 178, 74, 0.16);
  color: #ffe0a0;
}

.mini-sp-editor {
  width: 100%;
  display: grid;
  gap: 7px;
  border: 1px solid rgba(52, 64, 73, 0.78);
  border-radius: 8px;
  padding: 8px;
  background: rgba(12, 18, 22, 0.68);
}

.mini-sp-editor.compact {
  padding: 7px;
}

.mini-sp-editor-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: #a9bdc8;
  font-size: 0.72rem;
  font-weight: 850;
}

.mini-sp-editor-head strong {
  color: #eaf3f7;
  font-size: 0.78rem;
}

.mini-nature {
  width: min(260px, 100%);
  margin: 0;
}

.mini-nature span,
.mini-sp-grid label span {
  color: #a9bdc8;
  font-size: 0.68rem;
  font-weight: 850;
}

.mini-nature select {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 0.78rem;
}

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

.mini-sp-grid label {
  display: grid;
  grid-template-columns: 28px minmax(42px, 1fr) 40px;
  align-items: center;
  gap: 4px;
  margin: 0;
  min-width: 0;
}

.mini-sp-grid input {
  min-height: 28px;
  padding: 4px 5px;
  text-align: center;
  font-size: 0.78rem;
}

.mini-sp-grid b {
  color: #f2f6f8;
  font-size: 0.76rem;
  text-align: right;
}

.mini-sp-total {
  color: #b7c7d0;
  font-size: 0.68rem;
  line-height: 1.25;
}

.mini-sp-total.bad {
  color: #ff9289;
}

.threat-panel .mini-sp-grid,
.counters-panel .mini-sp-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 1700px) {
  .threat-panel .mini-sp-grid,
  .counters-panel .mini-sp-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .mini-sp-grid,
  .threat-panel .mini-sp-grid,
  .counters-panel .mini-sp-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================
   Header logo clickable crop
   ========================= */

.brand-block {
  pointer-events: none;
}

.topbar h1 {
  width: fit-content;
  max-width: 100%;
}

.brand-link {
  pointer-events: auto;
  width: clamp(260px, 17vw, 340px);
  height: calc(var(--topbar-height) - 18px);
  max-height: 82px;
  justify-content: center;
  overflow: hidden;
  border-radius: 4px;
}

.brand-link:focus-visible {
  outline: 2px solid rgba(63, 181, 138, 0.8);
  outline-offset: 3px;
}

.brand-logo {
  width: 100% !important;
  height: 100%;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain;
  transform: none;
}

@media (max-width: 1280px) and (min-width: 901px) {
  .brand-link {
    width: clamp(240px, 24vw, 295px);
    height: calc(var(--topbar-height) - 14px);
    max-height: 70px;
  }

  .brand-logo {
    transform: none;
  }
}

@media (max-width: 900px) {
  .brand-link {
    width: 260px;
    height: 62px;
    max-height: 62px;
  }

  .brand-logo {
    transform: none;
  }
}

@media (max-width: 620px) {
  .topbar {
    height: auto !important;
    min-height: 0 !important;
    padding-bottom: 8px !important;
  }

  .brand-block {
    height: 64px !important;
  }

  .brand-link {
    width: min(300px, 84vw);
    height: 64px;
    max-height: 64px;
  }

  .rules {
    justify-content: center !important;
    flex-wrap: wrap !important;
    overflow: visible !important;
    padding-bottom: 0;
  }

  .brand-logo {
    transform: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr !important;
    height: auto !important;
    min-height: 0 !important;
    gap: 4px;
    padding-top: 5px !important;
    padding-bottom: 8px !important;
  }

  .brand-block {
    grid-column: 1;
    height: 60px !important;
    justify-content: center !important;
  }

  .brand-link {
    width: min(300px, 82vw);
    height: 60px;
    max-height: 60px;
  }

  .rules {
    grid-column: 1;
    width: 100%;
    justify-content: center !important;
    flex-wrap: wrap !important;
    overflow: visible !important;
    padding-bottom: 0 !important;
  }

  .rules > * {
    flex: 0 0 auto;
  }
}

@media (max-width: 460px) {
  .brand-block {
    height: 58px !important;
  }

  .brand-link {
    width: min(260px, 84vw);
    height: 58px;
  }

  .top-link,
  .format-label,
  .format-button,
  .rule-group .rule-badge,
  .rule-group > span {
    min-height: 27px;
    font-size: 0.68rem;
  }
}

/* =========================
   Final header/counter polish
   ========================= */

.brand-block,
.topbar h1 {
  pointer-events: none !important;
}

.brand-link {
  pointer-events: auto !important;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  padding: 0 !important;
  line-height: 0;
}

.brand-logo {
  pointer-events: auto;
  width: clamp(270px, 20vw, 350px) !important;
  height: auto !important;
  max-width: min(100%, 350px) !important;
  max-height: 82px !important;
  object-fit: contain;
}

.top-link[href="about.html"],
.top-link[href$="about.html"] {
  border-color: rgba(63, 181, 138, 0.72);
  background: rgba(63, 181, 138, 0.18);
  color: #eafff5;
}

.top-link[href="about.html"]:hover,
.top-link[href$="about.html"]:hover {
  border-color: rgba(52, 157, 118, 0.88);
  background: rgba(52, 157, 118, 0.28);
  color: #ffffff;
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  min-width: 0;
  padding: 4px 10px 4px 5px;
  border: 1px solid rgba(141, 181, 199, 0.34);
  border-radius: 999px;
  background: #10161a;
  color: #d9e7ee;
  cursor: pointer;
}

.mode-switch:hover {
  border-color: rgba(63, 181, 138, 0.55);
  background: rgba(63, 181, 138, 0.1);
}

.mode-switch.active {
  border-color: rgba(230, 178, 74, 0.82);
  background: rgba(230, 178, 74, 0.16);
  color: #ffe3a8;
}

.mode-switch-track {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 38px;
  height: 21px;
  border-radius: 999px;
  background: #26313a;
  box-shadow: inset 0 0 0 1px rgba(169, 189, 200, 0.24);
}

.mode-switch-track span {
  width: 17px;
  height: 17px;
  margin-left: 2px;
  border-radius: 50%;
  background: #a9bdc8;
  transition: transform 150ms ease, background 150ms ease;
}

.mode-switch.active .mode-switch-track {
  background: rgba(230, 178, 74, 0.32);
  box-shadow: inset 0 0 0 1px rgba(230, 178, 74, 0.4);
}

.mode-switch.active .mode-switch-track span {
  transform: translateX(17px);
  background: #ffd36d;
}

.mode-switch-text {
  display: grid;
  gap: 1px;
  text-align: left;
  line-height: 1.05;
}

.mode-switch-text strong {
  font-size: 0.76rem;
}

.mode-switch-text small {
  color: #9fb4bf;
  font-size: 0.62rem;
  font-weight: 850;
}

.mode-switch.active .mode-switch-text small {
  color: #ffe5ad;
}

.threat-target {
  position: relative;
  border-color: rgba(63, 181, 138, 0.55);
  background: linear-gradient(180deg, rgba(63, 181, 138, 0.08), rgba(17, 23, 27, 0.98));
}

.threat-target-label {
  grid-column: 1 / -1;
  justify-self: start;
  margin-bottom: 2px;
  border: 1px solid rgba(63, 181, 138, 0.48);
  border-radius: 999px;
  padding: 2px 8px;
  background: rgba(63, 181, 138, 0.16);
  color: #c6ffe9;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0;
}

.suggestions-panel .suggestion-card {
  align-items: start;
}

.suggestions-panel .sprite-frame {
  place-self: start center;
}

.suggestions-panel .sprite-frame img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  object-fit: contain;
  object-position: center;
}

.mini-sp-grid label {
  grid-template-columns: 34px minmax(56px, 76px) minmax(42px, 1fr);
  gap: 7px;
}

.mini-sp-grid input {
  width: 76px;
  max-width: 100%;
  justify-self: start;
}

.mini-sp-grid b {
  min-width: 0;
  text-align: left;
}

.threat-target .mini-sp-editor,
.counter-threat-tools .mini-sp-editor {
  max-width: 100%;
}

@media (max-width: 760px) {
  .brand-logo {
    width: min(260px, 74vw) !important;
    max-height: 58px !important;
  }

  .threat-panel .threat-target .mini-sp-editor {
    max-height: 228px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .threat-panel .counters {
    min-height: 0;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 520px) {
  .brand-logo {
    width: min(238px, 72vw) !important;
    max-height: 52px !important;
  }

  .rules {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(100%, 360px);
    margin-inline: auto;
    justify-content: center !important;
    gap: 6px !important;
    overflow: visible !important;
  }

  body {
    overflow-x: hidden !important;
  }

  .app-shell {
    width: 100vw !important;
    max-width: 100vw !important;
    padding-inline: 8px !important;
    overflow-x: hidden !important;
  }

  .panel,
  .team-panel,
  .editor-panel,
  .side-panel {
    width: 100% !important;
    max-width: 100% !important;
  }

  .format-control,
  .top-link {
    width: 100%;
    justify-content: center;
  }

  .format-button {
    width: 100%;
    max-width: none !important;
  }

  .rule-group {
    display: contents !important;
  }

  .rule-group .rule-badge,
  .rule-group > span {
    justify-content: center;
    width: 100%;
  }

  .coffee-link {
    grid-column: 1 / -1;
    justify-self: center;
    width: auto;
    padding-inline: 14px;
  }

  .top-link[href="about.html"],
  .top-link[href$="about.html"],
  .top-link.active {
    justify-self: center !important;
    width: max-content !important;
    min-width: 0 !important;
    padding-inline: 14px !important;
  }

  .team-panel .team-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .quick-add,
  .team-panel .quick-add {
    grid-template-columns: 1fr !important;
  }

  .mode-switch {
    min-height: 32px;
  }

  .mini-sp-grid label {
    grid-template-columns: 32px minmax(58px, 72px) minmax(40px, 1fr);
  }

  .mini-sp-grid input {
    width: 72px;
  }
}

@media (max-width: 380px) {
  .mini-sp-grid label {
    grid-template-columns: 30px minmax(54px, 64px) minmax(38px, 1fr);
    gap: 5px;
  }

  .mini-sp-grid input {
    width: 64px;
  }
}

/* =========================
   Header hardening v2
   ========================= */

:root {
  --header-logo-width: clamp(210px, 16vw, 300px);
}

.topbar {
  display: grid !important;
  grid-template-columns: minmax(0, var(--header-logo-width)) minmax(0, 1fr) !important;
  align-items: center !important;
  column-gap: clamp(12px, 2vw, 28px) !important;
  row-gap: 6px !important;
  height: var(--topbar-height) !important;
  min-height: var(--topbar-height) !important;
  overflow: visible !important;
}

.brand-block {
  display: flex !important;
  grid-column: 1 !important;
  align-items: center !important;
  justify-content: center !important;
  width: var(--header-logo-width) !important;
  min-width: 0 !important;
  max-width: var(--header-logo-width) !important;
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
  pointer-events: none !important;
}

.topbar h1 {
  display: block !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  line-height: 0 !important;
  pointer-events: none !important;
}

.brand-link {
  display: inline-block !important;
  width: var(--header-logo-width) !important;
  height: auto !important;
  max-width: var(--header-logo-width) !important;
  max-height: none !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  line-height: 0 !important;
  overflow: visible !important;
  pointer-events: auto !important;
}

.brand-link:hover,
.brand-link:active,
.brand-link:focus,
.brand-link:focus-visible {
  background: transparent !important;
  box-shadow: none !important;
}

.brand-link:focus-visible {
  outline: 2px solid rgba(63, 181, 138, 0.75) !important;
  outline-offset: 3px !important;
}

.brand-logo {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: none !important;
  margin: 0 !important;
  border: 0 !important;
  background: transparent !important;
  object-fit: contain !important;
  object-position: center !important;
  transform: none !important;
}

.rules {
  grid-column: 2 !important;
  width: 100% !important;
  justify-content: flex-end !important;
  align-content: center !important;
}

@media (max-width: 1180px) {
  :root {
    --header-logo-width: clamp(190px, 28vw, 260px);
    --topbar-height: 116px;
  }

  .topbar {
    grid-template-columns: 1fr !important;
    height: auto !important;
    min-height: var(--topbar-height) !important;
    padding-top: 7px !important;
    padding-bottom: 9px !important;
  }

  .brand-block {
    grid-column: 1 !important;
    justify-self: center !important;
  }

  .rules {
    grid-column: 1 !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
    overflow: visible !important;
  }
}

@media (max-width: 760px) {
  :root {
    --header-logo-width: clamp(176px, 58vw, 236px);
    --topbar-height: 150px;
  }
}

@media (max-width: 520px) {
  :root {
    --header-logo-width: min(214px, 62vw);
    --topbar-height: 224px;
  }

  .brand-block,
  .brand-link {
    width: var(--header-logo-width) !important;
    max-width: var(--header-logo-width) !important;
  }
}

/* Header sizing final: scale logo by height so it never bleeds into content */
@media (min-width: 1181px) {
  :root {
    --topbar-height: 104px;
  }

  .topbar {
    grid-template-columns: max-content minmax(0, 1fr) !important;
    height: var(--topbar-height) !important;
    min-height: var(--topbar-height) !important;
    overflow: hidden !important;
    padding-left: clamp(20px, 2.4vw, 46px) !important;
  }

  .brand-block,
  .brand-link {
    width: auto !important;
    max-width: none !important;
  }

  .brand-logo {
    width: auto !important;
    height: 86px !important;
    max-height: 86px !important;
  }
}

@media (max-width: 1180px) {
  :root {
    --topbar-height: 158px;
  }

  .topbar {
    overflow: hidden !important;
  }

  .brand-block,
  .brand-link {
    width: auto !important;
    max-width: none !important;
  }

  .brand-logo {
    width: auto !important;
    height: 88px !important;
    max-height: 88px !important;
  }
}

@media (max-width: 760px) {
  :root {
    --topbar-height: 158px;
  }

  .brand-logo {
    width: auto !important;
    height: 62px !important;
    max-height: 62px !important;
  }
}

@media (max-width: 520px) {
  :root {
    --topbar-height: 224px;
  }

  .brand-logo {
    width: auto !important;
    height: 52px !important;
    max-height: 52px !important;
  }
}

/* Header dropdowns must float over the tabbed workspace */
.topbar {
  z-index: 9000 !important;
  overflow: visible !important;
}

.format-control {
  z-index: 9100 !important;
}

.format-control:focus-within,
.format-control:has(.format-menu:not([hidden])) {
  z-index: 9300 !important;
}

.format-menu {
  z-index: 9500 !important;
}

.app-shell,
.side-panel,
.side-tabs {
  position: relative;
  z-index: 1;
}

/* Landing page */
.landing-page {
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 100dvh;
  overflow: auto;
  background:
    radial-gradient(circle at 16% 12%, rgba(230, 178, 74, 0.13), transparent 32%),
    radial-gradient(circle at 84% 20%, rgba(63, 181, 138, 0.12), transparent 30%),
    linear-gradient(135deg, #101417 0%, #111a20 48%, #0d1114 100%);
}

.landing-shell {
  display: grid;
  place-items: center;
  flex: 1 0 auto;
  min-height: 0;
  width: 100%;
  padding: clamp(18px, 4vw, 48px) 18px clamp(24px, 5vw, 60px);
}

.landing-frame {
  display: grid;
  gap: 12px;
  width: min(1120px, 100%);
  align-content: center;
}

.landing-hero {
  display: grid;
  justify-items: center;
  width: 100%;
  text-align: center;
}

.landing-language {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 4px;
  min-height: 34px;
  border: 1px solid rgba(63, 181, 138, 0.55);
  border-radius: 999px;
  padding: 3px;
  background: rgba(9, 14, 17, 0.72);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}

.landing-language span {
  padding: 0 8px;
  color: #a9bac4;
  font-size: 0.76rem;
  font-weight: 900;
}

.landing-language button {
  min-height: 26px;
  border: 0;
  border-radius: 999px;
  padding: 0 10px;
  color: #dce9ee;
  background: transparent;
  font-size: 0.76rem;
  font-weight: 900;
}

.landing-language button:hover {
  background: rgba(63, 181, 138, 0.1);
  filter: none;
}

.landing-language button.active {
  color: #07110d;
  background: var(--accent);
}

.landing-banner-wrap {
  width: 100%;
  margin: 0 0 clamp(18px, 3vw, 30px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: #f6f6f4;
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.landing-banner {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 1;
  object-fit: contain;
  background: #f6f6f4;
}

.landing-logo {
  width: min(520px, 92vw);
  height: auto;
  margin-bottom: clamp(14px, 3vw, 28px);
}

.landing-kicker {
  margin: 0 0 10px;
  color: var(--accent-2);
  font-size: 0.84rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.landing-hero h1 {
  max-width: 820px;
  margin: 0;
  color: #f7fbfd;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 1.02;
}

.landing-copy {
  max-width: 720px;
  margin: 18px 0 0;
  color: #b8c8d2;
  font-size: clamp(1rem, 2.1vw, 1.22rem);
  line-height: 1.55;
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 28px;
}

.landing-button,
.landing-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  padding: 0 18px;
  color: #07110d;
  background: var(--accent);
  font-weight: 900;
  text-decoration: none;
}

.landing-link {
  border: 1px solid var(--line);
  color: #dce8ee;
  background: rgba(17, 23, 27, 0.82);
}

.landing-button:hover,
.landing-link:hover {
  filter: brightness(1.08);
}

.landing-footer {
  flex: 0 0 auto;
  position: static !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 9px 16px !important;
  line-height: 1.3 !important;
  text-align: center;
  white-space: normal !important;
  overflow: visible !important;
}

.landing-footer-set {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 8px;
  max-width: 1180px;
}

.landing-footer-set[hidden] {
  display: none !important;
}

.landing-footer span {
  overflow: visible;
  text-overflow: clip;
}

@media (max-width: 760px) {
  .landing-shell {
    padding: 10px 10px 16px;
  }

  .landing-frame {
    gap: 10px;
  }

  .landing-language {
    justify-self: center;
  }

  .landing-hero {
    width: 100%;
  }

  .landing-banner-wrap {
    width: 100%;
    margin-bottom: 16px;
    border-radius: 8px;
  }

  .landing-kicker {
    font-size: 0.72rem;
  }

  .landing-hero h1 {
    font-size: clamp(1.72rem, 9vw, 2.45rem);
    line-height: 1.05;
  }

  .landing-copy {
    margin-top: 12px;
    font-size: 0.96rem;
    line-height: 1.46;
  }

  .landing-actions {
    width: 100%;
    margin-top: 20px;
  }

  .landing-button,
  .landing-link {
    flex: 1 1 150px;
    min-height: 44px;
  }

  .landing-footer {
    justify-content: center !important;
    align-items: center !important;
    padding: 10px !important;
    font-size: 0.66rem !important;
    line-height: 1.35 !important;
  }

  .landing-footer-set {
    justify-content: center;
    gap: 3px 6px;
  }
}

@media (max-width: 430px) {
  .landing-shell {
    padding-inline: 8px;
  }

  .landing-banner-wrap {
    width: calc(100vw - 16px);
  }

  .landing-language {
    width: 100%;
    justify-content: center;
  }

  .landing-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* Compact descriptive text */
.info-collapse {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11171b;
}

.info-collapse > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
  padding: 9px 11px;
  color: #eaf3f7;
  cursor: pointer;
  font-weight: 900;
  list-style: none;
}

.info-collapse > summary::-webkit-details-marker {
  display: none;
}

.info-collapse > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid #9fb5c0;
  border-bottom: 2px solid #9fb5c0;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.info-collapse[open] > summary::after {
  transform: translateY(3px) rotate(225deg);
}

.info-collapse-body {
  padding: 0 11px 11px;
}

.info-collapse-body > p:first-child {
  margin-top: 0;
}

.strategy-box.info-collapse {
  padding: 0;
}

.card-details {
  margin-top: 8px;
}

.card-details .suggestion-explain {
  margin-top: 0;
}

.inline-label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.move-order-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

/* Final mobile header compaction for the builder */
@media (max-width: 760px) {
  :root {
    --topbar-height: 104px !important;
  }

  .topbar {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto auto !important;
    align-content: start !important;
    gap: 6px !important;
    height: var(--topbar-height) !important;
    min-height: var(--topbar-height) !important;
    padding: 6px 10px 5px !important;
    overflow: visible !important;
  }

  .brand-block {
    justify-self: center !important;
    height: 42px !important;
  }

  .brand-logo {
    width: auto !important;
    height: 42px !important;
    max-height: 42px !important;
  }

  .rules {
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    width: 100% !important;
    padding-bottom: 4px !important;
    gap: 6px !important;
  }

  .rules > *,
  .rule-group > * {
    flex: 0 0 auto !important;
  }

  .format-control,
  .top-link,
  .rule-group,
  .rule-badge,
  .rules > span {
    min-height: 28px !important;
  }

  .format-button,
  .top-link {
    min-height: 28px !important;
    padding-inline: 10px !important;
  }
}

@media (max-width: 520px) {
  :root {
    --topbar-height: 98px !important;
  }

  .topbar {
    height: var(--topbar-height) !important;
    min-height: var(--topbar-height) !important;
  }

  .brand-block {
    height: 36px !important;
  }

  .brand-logo {
    height: 36px !important;
    max-height: 36px !important;
  }
}

/* Final responsive polish for collapsible type analysis */
.type-planner-collapse {
  padding: 0;
}

.type-planner-collapse > .type-planner-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin: 0;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
}

.type-planner-collapse > .type-planner-head::-webkit-details-marker {
  display: none;
}

.type-planner-collapse > .type-planner-head span {
  justify-self: end;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.type-planner-collapse > .type-planner-head::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid #9fb5c0;
  border-bottom: 2px solid #9fb5c0;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.15s ease;
}

.type-planner-collapse[open] > .type-planner-head {
  border-bottom: 1px solid rgba(52, 64, 73, 0.7);
}

.type-planner-collapse[open] > .type-planner-head::after {
  transform: translateY(2px) rotate(225deg);
}

.type-planner-body {
  padding: 7px;
}

.type-planner-body .type-balance-summary {
  margin-bottom: 7px;
}

@media (max-width: 760px) {
  .type-planner-collapse > .type-planner-head {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 4px;
    padding: 8px;
  }

  .type-planner-collapse > .type-planner-head span {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: start;
    width: 100%;
    white-space: normal;
    line-height: 1.25;
  }

  .type-planner-collapse > .type-planner-head::after {
    grid-column: 2;
    grid-row: 1;
  }

  .type-planner-body {
    padding: 6px;
  }

  .type-balance-summary span {
    min-height: 0;
  }
}

@media (max-width: 520px) {
  .type-planner-collapse > .type-planner-head {
    min-height: 34px;
  }

  .type-planner-collapse > .type-planner-head span {
    font-size: 0.68rem;
  }

  .type-balance-summary {
    gap: 5px;
  }

  .type-balance-card {
    min-height: 26px;
  }
}

/* Final layout safety net for narrow screens */
@media (max-width: 1180px) {
  body:not(.landing-page):not(.about-page) {
    height: auto !important;
    min-height: 100dvh !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  .app-shell {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "team"
      "editor"
      "side" !important;
    grid-template-rows: auto !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    padding-inline: clamp(8px, 2vw, 14px) !important;
  }

  .panel,
  .team-panel,
  .editor-panel,
  .side-panel {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .team-panel,
  .editor-panel {
    max-height: none !important;
    overflow: visible !important;
  }

  .side-panel {
    height: min(760px, 82dvh) !important;
    min-height: 420px !important;
    overflow: hidden !important;
  }
}

@media (max-width: 760px) {
  .team-panel .section-head,
  .editor-panel .section-head {
    align-items: start !important;
    gap: 8px !important;
  }

  .slot-card,
  .suggestion-card,
  .counter-card {
    min-width: 0 !important;
  }

  .side-panel {
    height: min(720px, 78dvh) !important;
    min-height: 390px !important;
  }
}

@media (max-width: 600px) {
  .team-panel .section-head {
    grid-template-columns: 1fr !important;
  }

  .team-panel .team-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100% !important;
  }

  .team-panel .quick-add,
  .quick-add {
    grid-template-columns: 1fr !important;
  }

  .slot-card {
    grid-template-columns: 56px minmax(0, 1fr) 30px !important;
  }

  .slot-name,
  .slot-meta {
    min-width: 0;
  }

  .base-stats-line {
    gap: 3px;
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding-inline: 6px !important;
  }

  .panel {
    padding: 8px !important;
  }

  .slot-card {
    grid-template-columns: 50px minmax(0, 1fr) 28px !important;
    gap: 8px !important;
  }

  .slot-card .sprite-frame {
    width: 50px !important;
    height: 50px !important;
  }

  .team-panel .team-actions button {
    padding-inline: 5px !important;
  }
}
