:root {
  color-scheme: light;
  --ink: #18111f;
  --muted: #6f6578;
  --line: #ded5e7;
  --soft: #f7f2fa;
  --panel: #ffffff;
  --accent: #7a2fa0;
  --accent-dark: #53206f;
  --brand-black: #07050b;
  --brand-purple: #7a2fa0;
  --warn: #a15c00;
  --blue: #295a9b;
  --red: #9d3434;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: #f3eef7;
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

.shell {
  min-height: 100vh;
  padding: 24px;
}

.sponsor-footer {
  background: var(--brand-black);
  border-top: 4px solid var(--brand-purple);
  color: #fff;
  margin-top: 8px;
  padding: 20px 24px;
}

.sponsor-inner {
  align-items: center;
  display: flex;
  gap: 22px;
  justify-content: center;
  margin: 0 auto;
  max-width: 1440px;
}

.sponsor-label {
  color: #d8b6ec;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sponsor-logos {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}

.sponsor-logo {
  background: #fff;
  border-radius: 6px;
  display: block;
  object-fit: contain;
}

.entagile-logo {
  height: 58px;
  padding: 7px 12px;
  width: 176px;
}

.inhand-logo {
  height: 58px;
  padding: 8px 12px;
  width: 300px;
}

.topbar {
  align-items: center;
  background: var(--brand-black);
  border: 1px solid #23152d;
  border-left: 0;
  border-radius: 0;
  border-right: 0;
  border-top: 0;
  box-shadow: 0 14px 40px rgba(24, 17, 31, 0.16);
  display: flex;
  justify-content: space-between;
  margin: -24px -24px 18px;
  max-width: none;
  min-height: 112px;
  overflow: hidden;
  padding: 18px 24px;
  position: relative;
}

.topbar::after {
  background: #7a2fa0;
  bottom: 0;
  content: "";
  height: 4px;
  left: 0;
  position: absolute;
  right: 0;
}

.brand-lockup {
  align-items: center;
  display: flex;
  gap: 16px;
  min-width: 0;
}

.brand-logo {
  flex: 0 0 auto;
  height: 76px;
  object-fit: contain;
  width: 76px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
}

h2 {
  font-size: 22px;
}

.eyebrow {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: #d8b6ec;
}

.topbar h1 {
  color: #fff;
}

.status-pill {
  background: #f0e3f7;
  border: 1px solid #d5b5e6;
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px;
  white-space: nowrap;
}

.nav-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

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

.workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(280px, 340px) 1fr;
  margin: 0 auto;
  max-width: 1440px;
}

.management-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(280px, 360px) 1fr;
  margin: 0 auto;
  max-width: 1120px;
}

.management-list {
  align-self: start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.login-modal {
  align-items: center;
  background: rgba(23, 32, 27, 0.45);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 20;
}

.login-modal[hidden] {
  display: none;
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  max-width: 420px;
  padding: 22px;
  width: min(100%, 420px);
}

.modal-open {
  overflow: hidden;
}

.management-only[aria-busy="true"] {
  opacity: 0.55;
}

.home-tabs {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 auto 18px;
  max-width: 1440px;
}

.tournament-picker select {
  min-width: min(420px, 100%);
}

.tournament-picker[hidden] {
  display: none;
}

.topbar .tournament-picker {
  flex: 0 0 auto;
  min-width: 0;
}

.tab-button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
  min-height: 38px;
  min-width: 0;
  padding: 8px 14px;
  line-height: 1.1;
  white-space: normal;
}

.tab-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tab-panel {
  margin: 0 auto;
  max-width: 1440px;
  min-width: 0;
}

.dashboard-empty {
  min-height: 420px;
}

.dashboard-view {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.dashboard-content {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.dashboard-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 16px;
}

.dashboard-section h3,
.event-rank-card h4 {
  margin: 0;
}

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

.event-rank-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
}

.table-wrap {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 100%;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  background: #fbf8fc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

td {
  font-weight: 700;
}

.full-preview {
  max-width: 100%;
  min-width: 0;
  width: 100%;
}

.import-panel {
  align-self: start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  padding: 18px;
  position: sticky;
  top: 20px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 0;
  padding: 10px 11px;
}

.upload-target {
  align-items: center;
  border: 1px dashed #bda7ca;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 7px;
  justify-items: center;
  padding: 22px 14px;
  text-align: center;
}

.upload-target input {
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  position: absolute;
}

.upload-icon {
  align-items: center;
  background: var(--accent);
  border-radius: 6px;
  color: white;
  display: inline-flex;
  font-size: 13px;
  font-weight: 900;
  height: 40px;
  justify-content: center;
  width: 52px;
}

.upload-target small,
.message,
.saved-items {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.summary-grid div,
.player-summary div {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.summary-grid strong,
.player-summary strong {
  display: block;
  font-size: 23px;
  line-height: 1;
}

.summary-grid span,
.player-summary span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-top: 6px;
}

.player-summary {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 14px;
  max-width: 520px;
}

.player-picker select {
  min-width: 220px;
}

.player-match-grid {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.primary {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  min-height: 44px;
  padding: 11px 14px;
}

.secondary,
.danger {
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  min-height: 32px;
  padding: 7px 9px;
}

.secondary {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--accent-dark);
}

.topbar .secondary {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}

.topbar .secondary:hover,
.topbar .secondary:focus-visible {
  background: rgba(255, 255, 255, 0.15);
}

.topbar .status-pill {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(216, 182, 236, 0.5);
  color: #fff;
}

.topbar .slot-filter span {
  color: #d8b6ec;
}

.topbar .slot-filter select {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(255, 255, 255, 0.35);
  min-width: 0;
  width: min(240px, 28vw);
}

.danger {
  background: #fff5f3;
  border: 1px solid #efc6bf;
  color: var(--red);
}

.primary:disabled {
  background: #9eaaa3;
  cursor: not-allowed;
}

.secondary:disabled,
.danger:disabled {
  color: #9eaaa3;
  cursor: not-allowed;
}

.saved-list {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding-top: 16px;
}

.saved-list h2 {
  font-size: 16px;
}

.saved-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 10px;
}

.saved-item.active {
  background: #faf4fd;
  border-color: #cfa8e0;
}

.saved-meta {
  display: grid;
  gap: 4px;
}

.saved-title {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.saved-item strong {
  display: block;
  font-size: 13px;
}

.active-badge {
  background: #f0e3f7;
  border: 1px solid #d5b5e6;
  border-radius: 999px;
  color: var(--accent-dark);
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 900;
  padding: 3px 7px;
}

.saved-actions {
  display: grid;
  gap: 7px;
  grid-template-columns: 1fr 1fr;
}

.preview {
  max-width: 100%;
  min-width: 0;
}

.preview-head {
  align-items: end;
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}

.preview-tools {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: flex-end;
}

.slot-filter {
  align-items: center;
  display: flex;
  gap: 8px;
}

.slot-filter span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.slot-filter select {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  min-height: 36px;
  padding: 7px 28px 7px 10px;
}

.slot-filter select:disabled {
  color: #9eaaa3;
}

.panels {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.empty-state {
  align-content: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  min-height: 360px;
  padding: 24px;
  text-align: center;
}

.slot-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  overflow: hidden;
}

.slot-head {
  align-items: center;
  background: #fbf8fc;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
}

.slot-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.slot-title strong {
  font-size: 17px;
}

.slot-title span,
.slot-head time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.match-grid {
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  background: var(--line);
}

.match-card {
  background: #fff;
  display: grid;
  gap: 10px;
  min-width: 0;
  min-height: 188px;
  padding: 12px;
}

.match-top {
  align-items: start;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.match-name {
  font-size: 14px;
  font-weight: 900;
  min-width: 0;
  overflow-wrap: anywhere;
}

.court {
  background: #e6f0f6;
  border-radius: 6px;
  color: #174c83;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 900;
  padding: 4px 7px;
}

.side {
  border-left: 4px solid var(--blue);
  border-radius: 0 6px 6px 0;
  display: grid;
  gap: 4px;
  padding-left: 8px;
}

.side.b {
  border-left-color: var(--red);
}

.side.winner {
  background: #f5edf8;
  box-shadow: inset 0 0 0 1px rgba(122, 43, 159, 0.18);
  padding: 7px 8px;
}

.side.loser {
  background: #f2f4f7;
  box-shadow: inset 0 0 0 1px rgba(99, 87, 112, 0.12);
  color: #5f6673;
  padding: 7px 8px;
}

.team-line {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.team {
  align-items: center;
  display: flex;
  gap: 6px;
  font-size: 13px;
  font-weight: 900;
  min-width: 0;
  overflow-wrap: anywhere;
}

.winner-badge {
  background: var(--accent);
  border-radius: 999px;
  color: #fff;
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  padding: 4px 6px;
  text-transform: uppercase;
}

.score {
  border-radius: 6px;
  font-size: 18px;
  font-weight: 900;
  min-width: 32px;
  padding: 2px 6px;
  text-align: center;
}

.score-input {
  appearance: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
  min-height: 34px;
  padding: 2px 4px;
  text-align: center;
  width: 56px;
}

.score.win {
  background: #f0e3f7;
  color: var(--accent-dark);
}

.score-status {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  min-height: 16px;
}

.score-status.error {
  color: var(--red);
}

.players {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

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

  .import-panel {
    position: static;
  }

  .match-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

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

  .sponsor-footer {
    padding: 18px 14px;
  }

  .sponsor-inner {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  .sponsor-logos {
    gap: 10px;
  }

  .entagile-logo {
    height: 50px;
    width: 154px;
  }

  .inhand-logo {
    height: 50px;
    width: min(100%, 292px);
  }

  .topbar,
  .preview-head,
  .slot-head {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .topbar {
    margin: -8px -8px 14px;
    min-height: 0;
    padding: 12px 8px;
  }

  .brand-lockup {
    gap: 12px;
  }

  .brand-logo {
    height: 56px;
    width: 56px;
  }

  h1 {
    font-size: 29px;
  }

  .nav-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .home-tabs {
    gap: 3px;
    margin-bottom: 14px;
  }

  .tournament-picker {
    width: 100%;
  }

  .topbar .tournament-picker {
    flex: 1 1 100%;
  }

  .topbar .slot-filter select {
    flex: 1;
    width: auto;
  }

  .tab-button {
    font-size: 11px;
    min-height: 38px;
    overflow-wrap: anywhere;
    padding: 5px 3px;
  }

  .table-wrap {
    overflow-x: hidden;
  }

  table {
    min-width: 0;
    table-layout: fixed;
  }

  th,
  td {
    font-size: 10px;
    line-height: 1.15;
    overflow-wrap: anywhere;
    padding: 6px 3px;
    white-space: normal;
  }

  th {
    font-size: 10px;
  }

  .preview-tools {
    align-items: stretch;
    justify-content: flex-start;
  }

  .slot-filter {
    justify-content: space-between;
  }

  .slot-filter select {
    flex: 1;
    min-width: 0;
  }

  .player-summary {
    max-width: none;
  }

  .player-picker {
    width: 100%;
  }

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

  .event-rank-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-section {
    gap: 10px;
    padding: 8px;
  }

  .event-rank-card {
    padding: 8px;
  }

  .match-card {
    gap: 8px;
    min-height: 172px;
    padding: 7px;
  }

  .match-top {
    gap: 6px;
  }

  .match-name {
    font-size: 12px;
  }

  .court {
    font-size: 10px;
    padding: 3px 5px;
  }

  .side {
    border-left-width: 3px;
    padding-left: 6px;
  }

  .team-line {
    gap: 5px;
  }

  .team,
  .players {
    font-size: 11px;
  }

  .score {
    font-size: 15px;
    min-width: 27px;
    padding: 1px 4px;
  }

  .score-input {
    font-size: 14px;
    min-height: 30px;
    width: 48px;
  }
}

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