:root {
  --nord0: #2e3440;
  --nord1: #3b4252;
  --nord2: #434c5e;
  --nord3: #4c566a;
  --nord4: #d8dee9;
  --nord5: #e5e9f0;
  --nord6: #eceff4;
  --nord8: #88c0d0;
  --nord9: #81a1c1;
  --nord10: #5e81ac;

  --bg: #f4f8ff;
  --text: #253143;
  --topbar-bg: rgba(255, 255, 255, 0.86);
  --surface: rgba(255, 255, 255, 0.78);
  --surface-border: rgba(94, 129, 172, 0.35);
  --muted: #4c5d79;
  --chip-text: #f8fbff;
  --shadow: 0 10px 28px rgba(43, 61, 89, 0.15);
  --focus: rgba(94, 129, 172, 0.45);
}

body.theme-dark {
  --bg: #1f2531;
  --text: #e9edf5;
  --topbar-bg: rgba(39, 48, 63, 0.9);
  --surface: rgba(45, 57, 76, 0.74);
  --surface-border: rgba(136, 192, 208, 0.35);
  --muted: #b8c4d8;
  --chip-text: #eef5ff;
  --shadow: 0 14px 34px rgba(8, 12, 20, 0.4);
  --focus: rgba(136, 192, 208, 0.5);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% -10%, rgba(255, 203, 5, 0.26), transparent 36%),
    radial-gradient(circle at 94% 106%, rgba(54, 95, 145, 0.34), transparent 36%),
    var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--surface-border);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--muted);
}

h1 {
  margin: 0.25rem 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
}

.subtitle {
  margin: 0;
  max-width: 72ch;
  color: var(--muted);
  line-height: 1.35;
  font-size: 0.94rem;
}

main {
  padding: 1rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.legend p {
  margin: 0;
  padding: 0.45rem 0.7rem;
  border-radius: 0.65rem;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.88rem;
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(170px, 1fr);
  gap: 0.7rem;
  margin-bottom: 0.5rem;
}

.control-field {
  display: grid;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.control-field input,
.control-field select {
  width: 100%;
  border-radius: 0.65rem;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--text);
  padding: 0.5rem 0.62rem;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}

.control-field input:focus,
.control-field select:focus {
  outline: 2px solid var(--focus);
  outline-offset: 0.1rem;
}

.results-count {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(285px, 360px));
  gap: 0.9rem;
  justify-content: start;
}

.type-card {
  position: relative;
  border-radius: 1rem;
  border: 1px solid var(--surface-border);
  background:
    radial-gradient(circle at 1px 1px, rgba(94, 129, 172, 0.18) 1px, transparent 1.2px),
    var(--surface);
  background-size: 14px 14px, auto;
  box-shadow: var(--shadow);
  overflow: hidden;
}

body.theme-dark .type-card {
  background:
    radial-gradient(circle at 1px 1px, rgba(216, 222, 233, 0.14) 1px, transparent 1.2px),
    var(--surface);
  background-size: 14px 14px, auto;
}

.type-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.8rem;
  padding: 0.8rem 0.95rem;
  color: var(--chip-text);
}

.type-header h2 {
  margin: 0;
  font-size: 1.02rem;
}

.portrait-label {
  margin: 0.55rem 0.95rem 0;
  font-size: 0.76rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.card-body {
  padding: 0.8rem 0.95rem 1rem;
  display: grid;
  gap: 0.6rem;
}

.section-title {
  margin: 0 0 0.55rem;
  font-size: 0.83rem;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(94, 129, 172, 0.35);
  background: rgba(94, 129, 172, 0.12);
  font-weight: 800;
}

.section-title::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--nord10);
  box-shadow: 0 0 0 2px rgba(94, 129, 172, 0.2);
}

.row {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 0.45rem;
  align-items: start;
  margin: 0.24rem 0;
}

.row-label {
  margin: 0;
  font-weight: 700;
  font-size: 0.85rem;
}

.row-value {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.3;
}

.section-card {
  border-radius: 0.85rem;
  border: 1px solid var(--surface-border);
  background: rgba(236, 239, 244, 0.92);
  padding: 0.62rem 0.7rem;
  min-height: 8rem;
}

body.theme-dark .section-card {
  background: rgba(46, 52, 64, 0.92);
}

.offense-card .section-title {
  border-color: rgba(208, 135, 112, 0.45);
  background: rgba(208, 135, 112, 0.16);
}

.offense-card .section-title::before {
  background: #d08770;
  box-shadow: 0 0 0 2px rgba(208, 135, 112, 0.22);
}

.defense-card .section-title {
  border-color: rgba(163, 190, 140, 0.5);
  background: rgba(163, 190, 140, 0.16);
}

.defense-card .section-title::before {
  background: #a3be8c;
  box-shadow: 0 0 0 2px rgba(163, 190, 140, 0.24);
}

.portrait-strip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.95rem 0.2rem;
}

.portrait-item {
  width: 4.3rem;
  display: grid;
  justify-items: center;
  gap: 0.2rem;
}

.portrait-link {
  border-radius: 999px;
  border: 1px solid var(--surface-border);
  background: rgba(255, 255, 255, 0.45);
  width: 3rem;
  height: 3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: var(--shadow);
}

body.theme-dark .portrait-link {
  background: rgba(46, 52, 64, 0.5);
}

.portrait-img {
  width: 2.6rem;
  height: 2.6rem;
  object-fit: contain;
  display: block;
}

.portrait-name {
  font-size: 0.7rem;
  text-align: center;
  line-height: 1.1;
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: center;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: 0.2rem;
  color: var(--text);
  font-size: 0.85rem;
  user-select: none;
}

.theme-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-slider {
  width: 2.35rem;
  height: 1.35rem;
  border-radius: 999px;
  background: var(--nord3);
  border: 1px solid var(--surface-border);
  position: relative;
  transition: background 160ms ease;
}

.theme-slider::after {
  content: "";
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: var(--nord6);
  position: absolute;
  top: 0.14rem;
  left: 0.16rem;
  transition: transform 160ms ease;
}

.theme-switch input:checked + .theme-slider {
  background: var(--nord10);
}

.theme-switch input:checked + .theme-slider::after {
  transform: translateX(0.98rem);
}

.theme-switch:focus-within {
  outline: none;
}

.theme-switch input:focus-visible + .theme-slider {
  box-shadow: 0 0 0 2px var(--focus);
}

.footer {
  padding: 0 1rem 1.1rem;
  color: var(--muted);
  display: grid;
  gap: 0.35rem;
}

.footer-links {
  display: inline-flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.8rem;
  background: var(--surface);
}

.footer-links a:hover {
  text-decoration: underline;
}

.info-main {
  max-width: 900px;
  margin: 0 auto;
}

.info-card {
  border: 1px solid var(--surface-border);
  border-radius: 1rem;
  padding: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.info-card h2 {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
}

.info-card p {
  margin: 0 0 0.75rem;
  line-height: 1.45;
}

.info-card ul {
  margin: 0.2rem 0 0.8rem;
}

.meta-note {
  color: var(--muted);
  font-size: 0.86rem;
}

@media (max-width: 680px) {
  .type-grid {
    grid-template-columns: 1fr;
  }

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

  .row {
    grid-template-columns: 1fr;
    gap: 0.12rem;
  }
}
