:root{font-family:system-ui,-apple-system,Segoe UI,sans-serif;color:#1d2939;background:#f4f6f9}*{box-sizing:border-box}body{margin:0}header{background:#15243a;color:#fff;padding:18px max(20px,calc((100vw - 1180px)/2));display:flex;justify-content:space-between;gap:15px;flex-wrap:wrap;align-items:center}header strong{font-size:22px}header strong span{color:#9ee2bf}main{max-width:1180px;margin:25px auto;padding:0 20px}nav{display:flex;gap:7px}button{cursor:pointer;border:0;border-radius:8px;padding:10px 14px;font-weight:650;background:#e9eef5;color:#24364d}button.primary{background:#315b8a;color:#fff}button.good{background:#18794e;color:#fff}button.danger{background:#ffe9e9;color:#9b2222}button:disabled{opacity:.45;cursor:default}h1{margin:0 0 6px;color:#15243a}h2{font-size:18px;margin:0 0 14px;color:#15243a}h3{font-size:15px;margin:12px 0 6px}.muted{color:#68778b}.grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}.card{background:#fff;border:1px solid #e4e9f0;border-radius:14px;padding:18px;margin-bottom:16px;box-shadow:0 3px 12px #172b4408}table{width:100%;border-collapse:collapse;font-size:13px}th,td{padding:9px 5px;border-bottom:1px solid #e9eef3;text-align:right}th:first-child,td:first-child{text-align:left}th{color:#68778b}input,select,textarea{font:inherit;width:100%;border:1px solid #d6dee8;border-radius:8px;padding:9px;color:#1d2939}textarea{min-height:95px;resize:vertical}label{display:block;font-size:12px;font-weight:700;color:#68778b;margin:10px 0 5px}.row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.row>*{flex:1}.row button{flex:0 0 auto}.match{padding:13px 0;border-bottom:1px solid #e9eef3}.match:last-child{border:0}.scoregrid{display:grid;grid-template-columns:minmax(0,1fr) 42px minmax(0,1fr);gap:8px;align-items:center;text-align:center}.scoregrid .save{grid-column:1/-1;width:100%}.scoregrid input{max-width:180px;justify-self:center;text-align:center}.scoregrid .name{font-weight:700;overflow-wrap:anywhere}.note{border-left:3px solid #8eb5d6;background:#f7f9fc;border-radius:0 8px 8px 0;padding:10px;margin:9px 0}.body{white-space:pre-wrap;overflow-wrap:anywhere}.note small{display:block;color:#68778b;margin-top:5px}.tabs{display:flex;gap:7px;flex-wrap:wrap;margin-bottom:15px}.tabs button.selected{background:#15243a;color:white}.hidden{display:none!important}.notice{padding:12px;background:#fff8e8;border-radius:8px;margin-bottom:15px}.fixture{border:1px solid #e4e9f0;border-radius:9px;padding:12px;margin:9px 0}.link{border:0;background:none;padding:0;color:#315b8a;text-decoration:underline}.pill{display:inline-block;background:#eaf0f6;border-radius:20px;padding:4px 9px;font-size:12px}.section{margin-top:18px}#toast{position:fixed;bottom:20px;right:20px;background:#15243a;color:white;padding:13px;border-radius:8px;max-width:350px;z-index:2}#toast.error{background:#9b2222}@media(max-width:700px){.grid{grid-template-columns:1fr}.row.stackmobile{display:block}.row.stackmobile>*{margin:5px 0;width:100%}main{margin:18px auto}.scoregrid{grid-template-columns:minmax(0,1fr) 26px minmax(0,1fr)}}

/* Shared lightbox used for profiles, invitations and future interactive details. */
.app-modal{width:min(94vw,560px);max-height:min(85vh,850px);overflow-y:auto;border:1px solid #dce5ef;border-radius:16px;padding:22px;background:#fff;color:#1d2939;box-shadow:0 22px 70px #101c3440}
.app-modal::backdrop{background:rgba(12,24,43,.64);backdrop-filter:blur(3px)}
.modal-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;margin-bottom:16px}
.modal-heading h2{margin:0;font-size:21px}.modal-heading button{flex:0 0 auto;padding:5px 11px;font-size:19px}
.app-modal .modal-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:15px}
.app-modal input[readonly]{background:#f7f9fc}
@media(max-width:700px){.app-modal{padding:16px;max-height:90vh}}

/* Sections in the admin player-edit lightbox. */
.editor-section{padding:14px 0;border-top:1px solid #e4e9f0}
.editor-section:first-child{border-top:0;padding-top:0}
.editor-section h3{margin:0 0 8px}
.editor-section .fixture textarea{margin-top:9px}

/* Resizable List editors in both the player portal and admin lightbox. */
.list-editor{display:block;width:100%;min-height:180px;resize:both;max-width:100%;margin:9px 0 12px;white-space:pre-wrap}
.full-width{display:block;width:100%;margin-top:10px}

/* Red, full-width Edit button for previously recorded match scores. */
button.danger.edit-score{background:#b42318;color:#fff}
button.danger.edit-score:hover{background:#912018}
/* Keep the pairing table usable inside the player-profile lightbox. */
.pairings-scroll{max-width:100%;overflow-x:auto;margin:8px 0 18px}
.pairings-table th,.pairings-table td{white-space:nowrap}
.pairings-table th:not(:first-child),.pairings-table td:not(:first-child){text-align:center}

/* Dedicated PIN setup page. */
.invite-page{max-width:480px;margin:55px auto}
.invite-error{color:#a4262c;min-height:1.2em}

/* Public knockout sections: latest round first, above group standings. */
.knockout-fixture{display:flex;align-items:center;justify-content:center;gap:16px;flex-wrap:wrap;text-align:center}
.knockout-fixture span{min-width:100px;flex:1;overflow-wrap:anywhere}
.knockout-fixture strong{white-space:nowrap;color:#15243a}
.winner-card{text-align:center;border:2px solid #d3ae57;background:#fffaf0}
.winner-name{font-size:clamp(22px,4vw,34px);font-weight:800;color:#15243a}
.group-stage-heading{margin:20px 0 14px}
.standings-scroll{overflow-x:auto}
.standings-scroll table{min-width:300px}

/* Public knockout bracket: each side of the draw remains visually distinct. */
.knockout-halves{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
.knockout-half{min-width:0;border:1px solid #dce5ef;background:#f8fafc;border-radius:10px;padding:12px}
.knockout-half h3{margin:0 0 10px;color:#315b8a}
.knockout-half .fixture{background:#fff}
.bonus-row label{flex:1;margin:0;font-size:14px;color:#1d2939}
.bonus-row input{flex:0 1 180px}
@media(max-width:700px){.knockout-halves{grid-template-columns:1fr}.bonus-row input{flex:0 1 110px}}

/* Gentle green/red result badges for completed knockout matches. */
.knockout-score{display:inline-block;min-width:35px;padding:6px 9px;border-radius:7px;text-align:center;background:#eef2f7;color:#24364d}
.knockout-score-win{background:#d9f0df!important;color:#23653a!important}
.knockout-score-loss{background:#f8dede!important;color:#963939!important}
.knockout-vs{flex:0 0 auto!important;min-width:auto!important;color:#68778b;font-size:12px}

/* Shared win/loss/draw colours in knockout fixtures and player pairing history. */
.knockout-score-draw{background:#dceafe!important;color:#2456a0!important}
.pairing-result{display:inline-block;min-width:58px;padding:6px 9px;border-radius:7px;text-align:center;background:#eef2f7;color:#24364d;font-weight:700}
.pairing-result.knockout-score-win{background:#d9f0df;color:#23653a}
.pairing-result.knockout-score-loss{background:#f8dede;color:#963939}
.pairing-result.knockout-score-draw{background:#dceafe;color:#2456a0}

/* Small red counter on the Score Approval admin tab. */
.tabs button { position: relative; }
.approval-count { display: inline-flex; align-items: center; justify-content: center; min-width: 19px; height: 19px; margin-left: 7px; padding: 0 5px; border-radius: 999px; background: #c62828; color: white; font-size: 11px; font-weight: 750; line-height: 1; vertical-align: middle; }

/* Completed knockout winners: a subtle rounded green outline around the name. */
.knockout-fixture .knockout-player-name{display:inline-block;min-width:0;flex:1;padding:6px 9px;border:2px solid transparent;border-radius:9px;overflow-wrap:anywhere}
.knockout-fixture .knockout-player-winner{border-color:#71bd87;background:#eef9f0;color:#23653a;font-weight:700}

/* Group-stage player history: plain scores, with only the winning number bold.
   Result labels retain their green/red/blue colours. */
.pairing-score{display:inline-block;min-width:35px;padding:6px 9px;text-align:center;color:inherit;font-weight:400}
.pairing-score-winner{font-weight:700}


/* Mobile leaderboard: fit all eight standings columns within the screen.
   The table no longer imposes its former 440px minimum width. */
@media (max-width: 700px) {
  html, body { max-width: 100%; overflow-x: clip; }
  main { padding-inline: 10px; }
  .grid, .grid > *, .card { min-width: 0; }
  .card { padding: 12px; }
  .standings-scroll { width: 100%; max-width: 100%; overflow-x: visible; }
  .standings-table { width: 100%; min-width: 0; table-layout: fixed; font-size: 11px; }
  .standings-table th, .standings-table td {
    padding: 7px 2px;
    overflow-wrap: anywhere;
    word-break: normal;
  }
  .standings-table th:first-child, .standings-table td:first-child { width: 35%; }
  .standings-table th:not(:first-child), .standings-table td:not(:first-child) { width: calc(65% / 7); text-align: center; }
  .standings-table .link { font-size: inherit; overflow-wrap: anywhere; text-align: left; }

  /* Player profile popup uses the entire mobile viewport, with fixed
     header and footer and a vertically scrolling content area. */
  .app-modal.profile-modal {
    position: fixed;
    inset: 0;
    width: 100%; max-width: none;
    height: 100%; max-height: none;
    margin: 0; padding: 0;
    border: 0; border-radius: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
  }
  .app-modal.profile-modal:not([open]) { display: none; }
  .profile-modal .modal-heading {
    flex: 0 0 auto; margin: 0; padding: 16px;
    border-bottom: 1px solid #e4e9f0;
  }
  .profile-modal #modalBody {
    flex: 1 1 auto; min-height: 0;
    overflow-y: auto; overscroll-behavior: contain;
    padding: 12px 16px;
  }
  .profile-modal .modal-footer {
    flex: 0 0 auto; padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid #e4e9f0;
  }
  .profile-modal .pairings-scroll { overflow-x: visible; }
  .profile-modal .pairings-table { width: 100%; table-layout: fixed; font-size: 11px; }
  .profile-modal .pairings-table th, .profile-modal .pairings-table td {
    white-space: normal; overflow-wrap: anywhere; padding: 7px 3px;
  }
  .profile-modal .pairings-table th:first-child, .profile-modal .pairings-table td:first-child { width: 35%; }
  .profile-modal .pairing-result { min-width: 0; padding: 5px 3px; }
  .profile-modal .pairing-score { min-width: 0; padding: 5px 2px; }
  .knockout-fixture { gap: 6px; }
  .knockout-fixture .knockout-player-name { padding: 5px 3px; }
  .knockout-score { min-width: 26px; padding: 5px; }
}

/* The footer is part of the reusable modal but is shown for player profiles only. */
.modal-footer[hidden] { display: none !important; }

/* Automatically stack group cards when JavaScript detects a table that
   would overflow in the normal two-column layout. This is independent of
   the device breakpoint and also works for unusually long player names. */
.standings-grid.standings-stacked { grid-template-columns: minmax(0, 1fr); }
.standings-grid > .card { min-width: 0; }
