:root {
      --navy: #0B1F3A;
      --navy-dark: #061224;
      --slate: #475569;
      --nyy: #1D4E89;
      --nyy-bright: #2B6CB0;
      --nyy-soft: #EBF3FA;
      --sea: #006B6B;
      --sea-bright: #0E8A8A;
      --sea-soft: #E6F4F4;
      --bg: #F4F7FA;
      --card: #FFFFFF;
      --text: #1A2433;
      --muted: #526277;
      --border: #D9E2EC;
      --green: #0F7B4D;
      --green-bg: #E7F6EE;
      --amber: #B25E09;
      --amber-bg: #FEF3E2;
      --red: #B42318;
      --red-bg: #FEECEB;
      --purple: #5925DC;
      --purple-bg: #F4F0FF;
      --shadow: 0 4px 18px rgba(11, 31, 58, 0.06);
      --radius: 14px;
    }

    * { box-sizing: border-box; }
    html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

    body {
      margin: 0;
      font-family: 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
      background: var(--bg);
      color: var(--text);
      line-height: 1.68;
      font-size: 16px;
    }

    .num, td, th { font-variant-numeric: tabular-nums; }

    /* Hero Header */
    .hero {
      position: relative;
      overflow: hidden;
      background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 45%, var(--nyy) 74%, var(--sea) 100%);
      color: #FFFFFF;
      padding: 40px 20px 36px;
    }

    .hero::before {
      content: "";
      position: absolute;
      inset: 0;
      background-image: repeating-linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.03) 0 1px,
        transparent 1px 32px
      );
      pointer-events: none;
    }

    .hero-bg-svg {
      position: absolute;
      right: -36px;
      top: -28px;
      width: 340px;
      height: 340px;
      opacity: 0.1;
      pointer-events: none;
    }

    .container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
    .hero .container { position: relative; z-index: 1; }

    .hero-badge {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      background: rgba(255, 255, 255, 0.14);
      border: 1px solid rgba(255, 255, 255, 0.24);
      color: #EBF3FA;
      font-size: 13px;
      font-weight: 600;
      padding: 5px 12px;
      border-radius: 999px;
      letter-spacing: 0.02em;
      margin-bottom: 14px;
    }

    .hero h1 {
      margin: 0 0 12px;
      font-size: clamp(23px, 4vw, 35px);
      line-height: 1.28;
      font-weight: 800;
      letter-spacing: -0.01em;
    }

    .hero-subtitle {
      margin: 0 0 26px;
      font-size: clamp(14.5px, 2.2vw, 17px);
      color: rgba(255, 255, 255, 0.9);
      max-width: 880px;
    }

    .kpi-grid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 12px;
    }

    .kpi-card {
      background: rgba(255, 255, 255, 0.1);
      border: 1px solid rgba(255, 255, 255, 0.2);
      border-radius: 12px;
      padding: 14px 16px;
      backdrop-filter: blur(6px);
    }

    .kpi-card.kpi-nyy { border-top: 3px solid #60A5FA; }
    .kpi-card.kpi-sea { border-top: 3px solid #2DD4BF; }
    .kpi-card.kpi-gold { border-top: 3px solid #FBBF24; }

    .kpi-label { font-size: 12px; color: rgba(255, 255, 255, 0.82); margin-bottom: 4px; font-weight: 600; }
    .kpi-val { font-size: clamp(19px, 2.6vw, 24px); font-weight: 800; color: #FFFFFF; line-height: 1.2; margin-bottom: 4px; }
    .kpi-sub { font-size: 12px; color: #D9E8F7; line-height: 1.42; }

    /* Sticky Pill Nav */
    .sticky-nav {
      position: sticky;
      top: 0;
      z-index: 50;
      background: rgba(255, 255, 255, 0.95);
      backdrop-filter: blur(10px);
      border-bottom: 1px solid var(--border);
    }

    .nav-inner {
      max-width: 1100px;
      margin: 0 auto;
      padding: 10px 16px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    .nav-links {
      display: flex;
      align-items: center;
      gap: 8px;
      overflow-x: auto;
      scrollbar-width: none;
      padding-bottom: 2px;
    }

    .nav-links::-webkit-scrollbar { display: none; }

    .nav-pill {
      flex: 0 0 auto;
      text-decoration: none;
      color: var(--navy);
      background: var(--nyy-soft);
      font-size: 13px;
      font-weight: 600;
      padding: 6px 13px;
      border-radius: 999px;
      transition: background 0.18s, color 0.18s;
      white-space: nowrap;
    }

    .nav-pill:hover, .nav-pill:focus-visible { background: var(--navy); color: #FFFFFF; }

    .btn-print {
      flex: 0 0 auto;
      border: 1px solid var(--navy);
      background: var(--navy);
      color: #FFFFFF;
      font-size: 13px;
      font-weight: 600;
      padding: 6px 14px;
      border-radius: 999px;
      cursor: pointer;
      white-space: nowrap;
      transition: background 0.18s;
    }

    .btn-print:hover { background: var(--sea); border-color: var(--sea); }

    /* Main Content */
    main { padding: 28px 0 56px; }
    section { margin-bottom: 34px; scroll-margin-top: 66px; }

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

    .section-num {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 32px;
      height: 32px;
      border-radius: 9px;
      background: var(--navy);
      color: #FFFFFF;
      font-size: 15px;
      font-weight: 800;
      flex-shrink: 0;
    }

    .section-title {
      margin: 0;
      font-size: clamp(20px, 3vw, 24px);
      font-weight: 800;
      color: var(--navy);
      line-height: 1.3;
    }

    .card {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 22px;
      box-shadow: var(--shadow);
      margin-bottom: 18px;
    }

    .card h3 {
      margin: 0 0 12px;
      font-size: 18px;
      font-weight: 700;
      color: var(--navy);
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }

    .card h4 { margin: 16px 0 8px; font-size: 16px; font-weight: 700; color: var(--nyy); }
    p { margin: 0 0 12px; }
    p:last-child { margin-bottom: 0; }
    ul, ol { margin: 8px 0 12px; padding-left: 22px; }
    li { margin-bottom: 8px; }

    /* Summary Grid */
    .summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

    .summary-card {
      background: var(--card);
      border: 1px solid var(--border);
      border-top: 4px solid var(--green);
      border-radius: var(--radius);
      padding: 18px;
      box-shadow: var(--shadow);
    }

    .summary-card:nth-child(2) { border-top-color: var(--amber); }
    .summary-card:nth-child(3) { border-top-color: var(--nyy); }
    .summary-tag { font-size: 12px; font-weight: 700; color: var(--green); margin-bottom: 6px; display: block; }
    .summary-card:nth-child(2) .summary-tag { color: var(--amber); }
    .summary-card:nth-child(3) .summary-tag { color: var(--nyy); }
    .summary-card p { font-size: 14.5px; color: var(--text); }

    /* Badges & Pills */
    .badge {
      display: inline-block;
      font-size: 11.5px;
      font-weight: 700;
      padding: 2px 8px;
      border-radius: 999px;
      line-height: 1.4;
      white-space: nowrap;
      vertical-align: middle;
    }

    .badge-mlb { background: #E2E8F0; color: #334155; }
    .badge-nyy { background: var(--nyy-soft); color: var(--nyy); }
    .badge-sea { background: var(--sea-soft); color: var(--sea); }
    .badge-good { background: var(--green-bg); color: var(--green); }
    .badge-warn { background: var(--amber-bg); color: var(--amber); }
    .badge-bad { background: var(--red-bg); color: var(--red); }
    .badge-purple { background: var(--purple-bg); color: var(--purple); }

    /* Callouts */
    .callout {
      border-left: 4px solid var(--nyy);
      background: var(--nyy-soft);
      padding: 14px 16px;
      border-radius: 0 10px 10px 0;
      margin: 14px 0;
      font-size: 14.5px;
    }

    .callout-sea { border-left-color: var(--sea); background: var(--sea-soft); }
    .callout-warn { border-left-color: var(--amber); background: var(--amber-bg); }
    .callout-red { border-left-color: var(--red); background: var(--red-bg); }
    .callout-green { border-left-color: var(--green); background: var(--green-bg); }

    /* Grids */
    .chart-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin: 16px 0; }
    .two-col { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
    .three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

    .chart-box {
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 16px;
      background: #FAFCFF;
    }

    .chart-title {
      font-size: 14px;
      font-weight: 700;
      color: var(--navy);
      margin-bottom: 10px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-wrap: wrap;
      gap: 6px;
    }

    .chart-legend {
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      font-size: 12px;
      color: var(--muted);
      margin-bottom: 8px;
    }

    .legend-item { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
    .legend-swatch { width: 14px; height: 3.5px; border-radius: 2px; display: inline-block; }
    .legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
    svg.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }

    /* Bar Rows */
    .bar-row {
      display: grid;
      grid-template-columns: 140px 1fr 56px;
      align-items: center;
      gap: 10px;
      margin-bottom: 9px;
      font-size: 13.5px;
    }

    .bar-row:last-child { margin-bottom: 0; }
    .bar-label { font-weight: 700; color: var(--text); }
    .bar-track { height: 12px; background: #E2E8F0; border-radius: 999px; overflow: hidden; }
    .bar-fill { height: 100%; border-radius: 999px; }
    .fill-nyy { background: linear-gradient(90deg, var(--nyy), var(--nyy-bright)); }
    .fill-sea { background: linear-gradient(90deg, var(--sea), var(--sea-bright)); }
    .fill-good { background: linear-gradient(90deg, #0F7B4D, #16A34A); }
    .fill-warn { background: linear-gradient(90deg, #B25E09, #D97706); }
    .fill-bad { background: linear-gradient(90deg, #B42318, #DC2626); }
    .fill-slate { background: linear-gradient(90deg, #64748B, #94A3B8); }
    .bar-val { font-weight: 800; text-align: right; color: var(--navy); }

    /* Spotlight 6-Team Cards */
    .spotlight-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 14px;
      margin-top: 12px;
    }

    .spot-card {
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 16px;
      background: #FAFCFF;
      border-top: 4px solid var(--navy);
    }

    .spot-card.good { border-top-color: var(--green); }
    .spot-card.warn { border-top-color: var(--amber); }
    .spot-card.bad { border-top-color: var(--red); }
    .spot-card.sea { border-top-color: var(--sea); }
    .spot-card.purple { border-top-color: var(--purple); }

    .spot-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 8px;
      margin-bottom: 8px;
      flex-wrap: wrap;
    }

    .spot-name { font-size: 16px; font-weight: 800; color: var(--navy); }

    .spot-metrics {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 6px;
      margin: 10px 0;
      padding: 8px;
      background: #FFFFFF;
      border: 1px solid var(--border);
      border-radius: 8px;
      text-align: center;
    }

    .spot-m-lbl { font-size: 11px; color: var(--muted); font-weight: 600; display: block; }
    .spot-m-val { font-size: 13.5px; font-weight: 800; color: var(--navy); }
    .spot-card p { font-size: 13.5px; color: var(--text); }

    /* Filter Pills for 30-Team Archetypes */
    .filter-bar {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-bottom: 14px;
    }

    .filter-btn {
      border: 1px solid var(--border);
      background: #F8FAFC;
      color: var(--navy);
      font-size: 13px;
      font-weight: 700;
      padding: 7px 13px;
      border-radius: 999px;
      cursor: pointer;
      transition: all 0.16s;
    }

    .filter-btn:hover { background: #E2E8F0; }
    .filter-btn.active {
      background: var(--navy);
      color: #FFFFFF;
      border-color: var(--navy);
    }

    .archetype-group { margin-bottom: 20px; }
    .archetype-group.hidden { display: none; }

    .archetype-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 8px;
      padding: 10px 14px;
      border-radius: 10px;
      background: #F1F5F9;
      border-left: 5px solid var(--navy);
      margin-bottom: 10px;
    }

    .archetype-header.g-elite { border-left-color: var(--green); background: #ECFDF5; }
    .archetype-header.g-hollow { border-left-color: var(--amber); background: #FFFBEB; }
    .archetype-header.g-power { border-left-color: var(--nyy); background: #EFF6FF; }
    .archetype-header.g-pivot { border-left-color: var(--purple); background: #F5F3FF; }
    .archetype-header.g-slump { border-left-color: var(--red); background: #FEF2F2; }

    .archetype-title { font-size: 15.5px; font-weight: 800; color: var(--navy); }
    .archetype-desc { font-size: 13px; color: var(--muted); font-weight: 600; }

    .team-cards-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 10px;
    }

    .team-mini-card {
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 12px 14px;
      background: #FFFFFF;
    }

    .team-mini-card.hl-nyy { background: #F4F8FD; border-color: #93C5FD; }
    .team-mini-card.hl-sea { background: #F0FAFA; border-color: #5EEAD4; }

    .team-mini-top {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 6px;
      margin-bottom: 6px;
      flex-wrap: wrap;
    }

    .team-mini-name { font-size: 14.5px; font-weight: 800; color: var(--navy); }

    .team-mini-stats {
      font-size: 12px;
      color: var(--muted);
      font-weight: 600;
      margin-bottom: 6px;
      background: #F8FAFC;
      padding: 4px 8px;
      border-radius: 6px;
    }

    .team-mini-card p { font-size: 13px; color: var(--text); margin: 0; line-height: 1.55; }

    /* Mode Switch for 30-Team Table */
    .mode-switch {
      display: inline-flex;
      background: #EAF0F6;
      padding: 4px;
      border-radius: 999px;
      gap: 4px;
      margin-bottom: 10px;
    }

    .mode-btn {
      border: 0;
      background: transparent;
      color: var(--muted);
      font-size: 13px;
      font-weight: 700;
      padding: 6px 14px;
      border-radius: 999px;
      cursor: pointer;
    }

    .mode-btn.active { background: var(--navy); color: #FFFFFF; }
    .table-mode-panel { display: none; }
    .table-mode-panel.active { display: block; }
    .print-table-heading { display: none; font-weight: 800; color: var(--navy); margin: 14px 0 6px; }

    /* Tables */
    .table-hint { display: none; font-size: 12px; color: var(--muted); margin-bottom: 6px; }

    .table-wrap {
      overflow-x: auto;
      border: 1px solid var(--border);
      border-radius: 12px;
      background: #FFFFFF;
      margin: 10px 0;
    }

    table { width: 100%; border-collapse: collapse; font-size: 13.5px; text-align: left; }

    thead th {
      background: #F1F5F9;
      color: var(--navy);
      font-weight: 700;
      padding: 10px 9px;
      border-bottom: 2px solid var(--border);
      white-space: nowrap;
    }

    thead th.sortable { cursor: pointer; user-select: none; transition: background 0.15s; }
    thead th.sortable:hover { background: #E2E8F0; }
    thead th.sort-active { background: #DCE7F5; color: var(--nyy); }
    .sort-arrow { font-size: 11px; margin-left: 3px; opacity: 0.7; }

    tbody td { padding: 8px 9px; border-bottom: 1px solid #E8EEF5; vertical-align: middle; }
    tbody tr:last-child td { border-bottom: none; }
    tbody tr:hover { background: #F8FBFF; }
    tr.row-nyy { background: #EBF3FA !important; font-weight: 600; }
    tr.row-sea { background: #E6F4F4 !important; font-weight: 600; }
    tr.row-top { background: #F0FAF4; }
    tr.row-warn { background: #FEF3E2; }
    tr.row-bad { background: #FEECEB; }

    .text-right { text-align: right; }
    .table-note { font-size: 13px; color: var(--muted); margin-top: 8px; }

    /* Tabs */
    .scenario-tabs {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 10px;
      background: #EAF0F6;
      padding: 6px;
      border-radius: 14px;
      margin-bottom: 18px;
    }

    .tab-btn {
      border: 0;
      background: transparent;
      border-radius: 10px;
      padding: 11px 12px;
      cursor: pointer;
      text-align: left;
      transition: all 0.18s;
      color: var(--muted);
    }

    .tab-btn-title { display: block; font-size: 14.5px; font-weight: 800; color: var(--navy); margin-bottom: 2px; }
    .tab-btn-sub { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
    .tab-btn[aria-selected="true"] { background: #FFFFFF; box-shadow: 0 3px 10px rgba(11, 31, 58, 0.12); }
    .tab-btn[aria-selected="true"].tab-both { border-left: 4px solid var(--navy); }
    .tab-btn[aria-selected="true"].tab-nyy { border-left: 4px solid var(--nyy); }
    .tab-btn[aria-selected="true"].tab-sea { border-left: 4px solid var(--sea); }

    .tab-panel { display: none; }
    .tab-panel.active { display: block; animation: fadeIn 0.22s ease; }

    .print-tab-heading {
      display: none;
      font-size: 16px;
      font-weight: 800;
      color: var(--navy);
      margin: 18px 0 10px;
      padding-bottom: 6px;
      border-bottom: 2px solid var(--navy);
    }

    @keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

    .footer {
      text-align: center;
      font-size: 13px;
      color: var(--muted);
      padding: 20px 16px 36px;
      border-top: 1px solid var(--border);
      background: #FFFFFF;
    }

    /* Mobile Responsive */
    @media (max-width: 860px) {
      .kpi-grid { grid-template-columns: repeat(2, 1fr); }
      .summary-grid, .chart-grid-2, .two-col, .three-col, .spotlight-grid, .team-cards-grid { grid-template-columns: 1fr; }
      .scenario-tabs { grid-template-columns: 1fr; }
      .table-hint { display: block; }
    }

    @media (max-width: 520px) {
      .hero { padding: 28px 14px 24px; }
      .card { padding: 16px; }
      .bar-row { grid-template-columns: 108px 1fr 48px; gap: 8px; }
      .spot-metrics { grid-template-columns: repeat(2, 1fr); }
    }

    /* Print / PDF Optimization */
    @media print {
      @page { size: A4; margin: 13mm 11mm; }
      body {
        background: #FFFFFF;
        font-size: 10.5pt;
        line-height: 1.5;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
      }
      .sticky-nav, .btn-print, .scenario-tabs, .table-hint, .filter-bar, .mode-switch { display: none !important; }
      .hero { padding: 16px 18px; border-radius: 10px; margin-bottom: 12px; }
      .container { max-width: 100%; padding: 0; }
      main { padding: 8px 0 20px; }
      .card, .summary-card, .chart-box, .callout, .spot-card, .team-mini-card {
        box-shadow: none !important;
        break-inside: avoid;
      }
      .table-wrap { overflow: visible !important; }
      table { font-size: 8.8pt; }
      thead th, tbody td { padding: 5px 6px; }
      tr { break-inside: avoid; }
      .tab-panel, .table-mode-panel { display: block !important; margin-bottom: 18px; }
      .archetype-group { display: block !important; }
      .print-tab-heading, .print-table-heading { display: block !important; }
      .kpi-grid { grid-template-columns: repeat(4, 1fr); }
    }
