:root {
  --bg: #0f0f10;
  --panel: #151617;
  --gold: #ffe65a;
  --gold-dark: #aa8100;
  --text: #f4f4f4;
  --muted: #9aa0a6;
  --border: #34373b;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, select { font: inherit; }

.viewer-header {
  min-height: 82px;
  padding: 10px 20px;
  border-bottom: 1px solid #ffffff18;
  display: grid;
  grid-template-columns: 70px 1fr auto;
  align-items: center;
  gap: 16px;
}
.logo-link img { display: block; width: 58px; height: 58px; object-fit: contain; }
.viewer-header h1 {
  margin: 0;
  color: var(--gold);
  text-align: center;
  font-size: clamp(24px, 4vw, 40px);
}
.header-button, .category-switch button {
  border: 1px solid var(--gold-dark);
  border-radius: 12px;
  background: #121315;
  color: var(--gold);
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}
.category-switch button:disabled {
  border-color: #4a4532;
  background: #171717;
  color: #716b50;
  cursor: not-allowed;
  opacity: .72;
}
.header-button { padding: 10px 18px; }
.viewer-main { width: min(1040px, 100%); margin: 0 auto; padding: 22px; }
.viewer-controls {
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto auto;
  align-items: end;
  gap: 14px;
  margin-bottom: 20px;
}
.category-switch { display: flex; gap: 8px; }
.category-switch button { min-height: 44px; padding: 8px 16px; }
.category-switch button.active {
  background: linear-gradient(#ffe87b, #f2bc17);
  color: #111;
}
.match-picker { display: grid; gap: 5px; }
.match-picker span { color: var(--gold); font-size: 12px; font-weight: 900; }
.match-picker select {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--gold-dark);
  border-radius: 12px;
  background: #08090a;
  color: var(--text);
  font-weight: 800;
}
.fixture-date, .release-status {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1b1d;
  font-weight: 800;
  white-space: nowrap;
}
.release-status.is-open { border-color: #3ab66c; color: #72df98; }
.viewer-message {
  margin: 24px auto;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}
.viewer-message.error { border-color: #8c3434; color: #ff9b9b; }
.teams-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}
.team-card {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 14px 34px #00000045;
}
.team-role {
  margin-bottom: 4px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  letter-spacing: 1px;
}
.team-name {
  min-height: 58px;
  margin: 0;
  display: grid;
  place-items: center;
  color: var(--gold);
  text-align: center;
  font-size: clamp(25px, 3vw, 34px);
  line-height: 1.05;
}
.players-section { margin-top: 22px; }
.players-section h3 {
  margin: 0 0 10px;
  color: var(--gold);
  text-align: center;
  font-size: 20px;
}
.player-row {
  min-height: 42px;
  margin: 7px 0;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}
.player-number {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: #111;
  font-weight: 900;
}
.player-slot {
  min-width: 0;
  height: 42px;
  padding: 0 42px 0 13px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  background: #fff;
  color: #151515;
  font-weight: 750;
}
.player-slot.empty { border: 1px dashed #c7c7c7; background: #f0f0f0; }
.player-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-button {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 30px;
  height: 30px;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
}
.player-photo-modal[hidden] { display: none; }
.player-photo-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 16px;
}
.player-photo-backdrop { position: absolute; inset: 0; background: #000c; }
.player-photo-dialog {
  position: relative;
  z-index: 1;
  width: min(340px, calc(100vw - 32px));
  padding: 18px;
  border: 1px solid var(--gold-dark);
  border-radius: 18px;
  background: #121418;
  text-align: center;
}
.player-photo-dialog h2 { margin: 0 40px 14px; color: var(--gold); }
.player-photo-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 1px solid #ffffff2c;
  border-radius: 50%;
  background: #08090b;
  color: white;
  cursor: pointer;
  font-size: 24px;
}
.player-photo-frame {
  width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 14px;
  background: #08090b;
}
.player-photo-frame img { width: 100%; height: 100%; object-fit: contain; }
.player-profile-btn {
  width: 100%;
  min-height: 38px;
  margin-top: 12px;
  padding: 7px 12px;
  border: 1px solid var(--gold-dark);
  border-radius: 10px;
  background: var(--gold);
  color: #111;
  font-weight: 900;
  cursor: pointer;
}
.player-profile-modal[hidden] { display: none !important; }
.player-profile-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 14px;
}
.player-profile-backdrop { position: absolute; inset: 0; background: #000e; }
.player-profile-dialog {
  position: relative;
  z-index: 1;
  width: min(920px, calc(100vw - 28px));
  height: min(820px, calc(100vh - 28px));
  overflow: hidden;
  border: 1px solid var(--gold-dark);
  border-radius: 16px;
  background: var(--bg);
  box-shadow: 0 24px 70px #000b;
}
.player-profile-dialog iframe { width: 100%; height: 100%; border: 0; background: var(--bg); }
.player-profile-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  background: #08090b;
  color: white;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.player-photo-status {
  min-height: 20px;
  margin-top: 10px;
  color: #c9d0db;
  font-size: 13px;
  font-weight: 700;
}

@media (min-width: 681px) {
  body { zoom: .5; }
}
@media (max-width: 900px) {
  .viewer-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .viewer-header {
    min-height: 44px;
    padding: 4px 6px;
    grid-template-columns: 30px 1fr auto;
    gap: 5px;
  }
  .logo-link img { width: 28px; height: 28px; }
  .viewer-header h1 { font-size: 15px; }
  .header-button { padding: 5px 7px; border-radius: 8px; font-size: 9px; }
  .viewer-main { padding: 7px 5px; }
  .viewer-controls {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: stretch;
    gap: 5px;
    margin-bottom: 7px;
  }
  .category-switch { gap: 3px; }
  .category-switch button { flex: 1; }
  .category-switch button,
  .match-picker select,
  .fixture-date,
  .release-status {
    min-height: 30px;
    padding: 3px 6px;
    border-radius: 7px;
    font-size: 8px;
  }
  .match-picker span { font-size: 8px; }
  .fixture-date,
  .release-status { white-space: normal; text-align: center; line-height: 1.05; }
  .teams-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }
  .team-card {
    padding: 7px 5px;
    border-radius: 10px;
    box-shadow: none;
  }
  .team-role { margin-bottom: 1px; font-size: 7px; }
  .team-name {
    min-height: 27px;
    font-size: 14px;
    line-height: 1;
  }
  .players-section { margin-top: 8px; }
  .players-section h3 { margin-bottom: 4px; font-size: 10px; }
  .player-row {
    min-height: 25px;
    margin: 3px 0;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 3px;
  }
  .player-number {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    font-size: 9px;
  }
  .player-slot {
    height: 25px;
    padding: 0 24px 0 5px;
    border-radius: 6px;
    font-size: 9px;
  }
  .photo-button {
    right: 2px;
    width: 21px;
    height: 21px;
    font-size: 11px;
  }
}
