:root {
        color-scheme: light;
        --bg: #f6f7f3;
        --panel: #ffffff;
        --text: #1f2933;
        --muted: #64707d;
        --line: #dde3ea;
        --primary: #146c5f;
        --primary-dark: #0f574d;
        --accent: #d94841;
        --team-a: #e6f4f1;
        --team-b: #f8eee1;
        --team-c: #eaf0fb;
        --players-per-tier: 3;
        --pool-table-min-width: 360px;
      }

      * {
        box-sizing: border-box;
      }

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

      main {
        width: min(1380px, calc(100% - 32px));
        margin: 0 auto;
        padding: 36px 0 48px;
      }

      header {
        display: flex;
        align-items: end;
        justify-content: space-between;
        gap: 20px;
        margin-bottom: 24px;
      }

      h1 {
        margin: 0;
        font-size: 30px;
        font-weight: 800;
        letter-spacing: 0;
      }

      .actions {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
      }

      .settings {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        align-items: end;
        margin-bottom: 20px;
        padding: 14px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--panel);
      }

      .setting-field {
        display: grid;
        gap: 6px;
      }

      .setting-field label {
        color: var(--muted);
        font-size: 13px;
        font-weight: 800;
      }

      .setting-field input {
        width: 132px;
      }

      button {
        min-height: 42px;
        border: 1px solid transparent;
        border-radius: 8px;
        padding: 0 16px;
        font: inherit;
        font-weight: 700;
        cursor: pointer;
      }

      button:focus-visible,
      input:focus-visible {
        outline: 3px solid rgba(20, 108, 95, 0.24);
        outline-offset: 2px;
      }

      .primary {
        background: var(--primary);
        color: #ffffff;
      }

      .primary:hover {
        background: var(--primary-dark);
      }

      .secondary {
        background: #ffffff;
        border-color: var(--line);
        color: var(--text);
      }

      .secondary:hover {
        border-color: #b9c4ce;
      }

      .workspace {
        display: grid;
        grid-template-columns: minmax(300px, 0.9fr) minmax(420px, 1.15fr) minmax(320px, 0.95fr);
        gap: 20px;
        align-items: start;
      }

      .section-title {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 12px;
      }

      h2 {
        margin: 0;
        font-size: 18px;
      }

      .count {
        color: var(--muted);
        font-size: 14px;
        font-weight: 700;
        white-space: nowrap;
      }

      .pool-table-wrap {
        overflow-x: auto;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--panel);
      }

      table {
        width: 100%;
        min-width: var(--pool-table-min-width);
        border-collapse: collapse;
      }

      th,
      td {
        border-bottom: 1px solid var(--line);
        padding: 10px 12px;
        text-align: center;
        white-space: nowrap;
      }

      th {
        background: #edf2f1;
        color: #33414d;
        font-size: 13px;
        font-weight: 800;
      }

      td:first-child,
      th:first-child {
        position: sticky;
        left: 0;
        min-width: 96px;
        text-align: left;
      }

      td:first-child {
        z-index: 1;
        background: inherit;
      }

      th:first-child {
        z-index: 2;
        background: #edf2f1;
      }

      tbody tr {
        background: var(--panel);
      }

      tbody tr:hover {
        background: #f7faf9;
      }

      tbody tr:last-child td {
        border-bottom: 0;
      }

      .tier-checkbox {
        width: 18px;
        height: 18px;
        min-height: auto;
        accent-color: var(--primary);
        cursor: pointer;
      }

      .tier-choice {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        min-height: 28px;
        cursor: pointer;
      }

      .tier-choice-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
      }

      .tiers {
        display: grid;
        gap: 12px;
      }

      .tier {
        display: grid;
        grid-template-columns: 88px 1fr;
        gap: 12px;
        align-items: center;
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 14px;
      }

      .tier-label {
        display: grid;
        gap: 4px;
      }

      .tier-label strong {
        font-size: 18px;
      }

      .tier-label span {
        color: var(--muted);
        font-size: 13px;
      }

      .players {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
        gap: 10px;
      }

      input[type="number"],
      input[type="text"] {
        width: 100%;
        min-height: 42px;
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 0 12px;
        background: #fbfcfd;
        color: var(--text);
        font: inherit;
      }

      input[type="text"][readonly] {
        cursor: default;
      }

      input::placeholder {
        color: #9aa5af;
      }

      .message {
        min-height: 22px;
        margin-top: 12px;
        color: var(--accent);
        font-size: 14px;
        font-weight: 700;
      }

      .results {
        display: grid;
        gap: 12px;
      }

      .team {
        min-height: 184px;
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 16px;
        background: var(--panel);
      }

      .team:nth-child(1) {
        background: var(--team-a);
      }

      .team:nth-child(2) {
        background: var(--team-b);
      }

      .team:nth-child(3) {
        background: var(--team-c);
      }

      .team h3 {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin: 0 0 12px;
        font-size: 17px;
      }

      .team-count {
        color: var(--muted);
        font-size: 13px;
      }

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

      .team li {
        display: flex;
        justify-content: space-between;
        gap: 10px;
        border-bottom: 1px solid rgba(31, 41, 51, 0.12);
        padding-bottom: 8px;
        font-size: 15px;
      }

      .team li:last-child {
        border-bottom: 0;
        padding-bottom: 0;
      }

      .badge {
        flex: 0 0 auto;
        color: var(--muted);
        font-size: 13px;
        font-weight: 800;
      }

      .empty {
        display: grid;
        min-height: 184px;
        place-items: center;
        border: 1px dashed #b9c4ce;
        border-radius: 8px;
        color: var(--muted);
        font-weight: 700;
        text-align: center;
      }

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

        .results-section {
          grid-column: 1 / -1;
        }
      }

      @media (max-width: 760px) {
        body {
          background: #f8faf7;
        }

        main {
          width: min(100% - 20px, 1380px);
          padding: 18px 0 32px;
        }

        header {
          align-items: stretch;
          flex-direction: column;
          gap: 14px;
          margin-bottom: 14px;
        }

        h1 {
          font-size: 24px;
        }

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

        .actions .primary {
          grid-column: 1 / -1;
        }

        .actions button {
          min-height: 46px;
          padding: 0 12px;
        }

        .settings {
          display: grid;
          grid-template-columns: 1fr 1fr;
          gap: 10px;
          margin-bottom: 14px;
          padding: 12px;
        }

        .setting-field input {
          width: 100%;
          min-height: 46px;
        }

        .workspace {
          grid-template-columns: 1fr;
          gap: 16px;
        }

        .results-section {
          grid-column: auto;
        }

        .section-title {
          margin-bottom: 10px;
        }

        h2 {
          font-size: 17px;
        }

        .pool-table-wrap {
          overflow-x: auto;
          border: 1px solid var(--line);
          background: var(--panel);
        }

        table {
          table-layout: fixed;
        }

        thead {
          display: table-header-group;
        }

        tbody tr {
          display: table-row;
          background: var(--panel);
        }

        th,
        td {
          padding: 8px 6px;
          text-align: center;
          white-space: nowrap;
        }

        th:first-child,
        td:first-child {
          position: sticky;
          left: 0;
          width: 76px;
          min-width: 76px;
          max-width: 76px;
          padding-left: 10px;
          font-size: 14px;
          text-align: left;
        }

        td:first-child {
          background: var(--panel);
          font-weight: 800;
        }

        th:first-child {
          background: #edf2f1;
        }

        .tier-choice {
          justify-content: center;
          width: 100%;
          min-height: 34px;
          padding: 0;
        }

        .tier-choice:has(.tier-checkbox:checked) {
          border-radius: 8px;
          background: #e9f5f1;
          color: #0f574d;
        }

        .tier-choice-text {
          position: absolute;
          width: 1px;
          height: 1px;
          overflow: hidden;
          clip: rect(0 0 0 0);
          white-space: nowrap;
        }

        .tier-checkbox {
          width: 20px;
          height: 20px;
        }

        .tier {
          grid-template-columns: 1fr;
          padding: 12px;
        }

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

        input[type="number"],
        input[type="text"] {
          min-height: 44px;
        }

        .team {
          min-height: auto;
          padding: 14px;
        }

        .empty {
          min-height: 120px;
          padding: 20px 12px;
        }
      }

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