* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: #14161a;
  color: #e8e8e8;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: #1d2025;
  border-bottom: 1px solid #2a2e35;
}

.topbar h1 {
  font-size: 18px;
  margin: 0;
}

.status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
}

.status--down { background: #4a1f1f; color: #ff8585; }
.status--up { background: #1f4a2a; color: #85ffa3; }

.sound-toggle {
  margin-left: auto;
  flex: 0 0 auto;
  background: #2a2e35;
  border: 1px solid #2a2e35;
  border-radius: 6px;
  color: #9aa0ab;
  font-size: 15px;
  line-height: 1;
  padding: 6px 10px;
  cursor: pointer;
}

.sound-toggle:hover {
  background: #383e48;
  color: #e8e8e8;
}

.sound-toggle.active {
  background: #1f3a4a;
  border-color: #2e6080;
  color: #7acfff;
}

.global-settings {
  display: flex;
  gap: 12px;
  padding: 12px 16px 0;
}

.global-settings label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #9aa0ab;
  flex: 1;
  min-width: 0;
  max-width: 240px;
}


.global-settings input {
  width: 100%;
  min-width: 0;
  background: #1d2025;
  border: 1px solid #2a2e35;
  border-radius: 4px;
  color: #e8e8e8;
  padding: 6px 8px;
  font-size: 13px;
}

.global-overrides {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  padding: 10px 16px 0;
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.switch-text {
  font-size: 12px;
  color: #c4c8cf;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.switch-text .optional-tag {
  font-size: 10px;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  display: inline-block;
  width: 34px;
  height: 20px;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.switch-track {
  position: absolute;
  inset: 0;
  background: #2a2e35;
  border: 1px solid #383e48;
  border-radius: 999px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.switch-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 16px;
  height: 16px;
  background: #9aa0ab;
  border-radius: 50%;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.switch input:checked ~ .switch-track {
  background: #1f3a4a;
  border-color: #2e6080;
}

.switch input:checked ~ .switch-track .switch-thumb {
  transform: translateX(14px);
  background: #7acfff;
}

.switch input:focus-visible ~ .switch-track {
  outline: 2px solid #2e6080;
  outline-offset: 2px;
}

.switch-label:hover .switch-track {
  border-color: #454c58;
}

.teams-section {
  padding: 16px 16px 0;
}

.teams-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.teams-header h2 {
  font-size: 15px;
  margin: 0;
  color: #c4c8cf;
}

.teams-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.teams-updated {
  font-size: 11px;
  color: #6a7280;
}

.teams-header button,
.swapTeamsBtn {
  background: #2a2e35;
  border: 1px solid #2a2e35;
  border-radius: 4px;
  color: #e8e8e8;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.teams-header button:hover,
.swapTeamsBtn:hover {
  background: #383e48;
}

.swapTeamsBtn--suggested {
  background: #4a3200;
  border-color: #e0a020;
  color: #ffd479;
  box-shadow: 0 0 0 2px rgba(224, 160, 32, 0.35);
  animation: swap-suggested-pulse 1.4s ease-in-out infinite;
}

.swapTeamsBtn--suggested:hover {
  background: #5c3f00;
}

@keyframes swap-suggested-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(224, 160, 32, 0.35); }
  50% { box-shadow: 0 0 0 5px rgba(224, 160, 32, 0.15); }
}

.teams-header button:disabled {
  opacity: 0.5;
  cursor: default;
}

.teams-list {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}

.team-card {
  background: #1d2025;
  border: 1px solid #2a2e35;
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.team-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.teamLogo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex: 0 0 auto;
}

.team-identity {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.team-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-tricode {
  font-size: 10px;
  color: #6a7280;
}

.editTeamBtn {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid #2a2e35;
  border-radius: 5px;
  color: #6a7280;
  font-size: 12px;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
}

.editTeamBtn:hover {
  background: #2a2e35;
  color: #e8e8e8;
}

.team-score-badge {
  flex: 0 0 auto;
  background: #1f3a4a;
  border: 1px solid #2e6080;
  color: #7acfff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
}

.team-roster {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 8px;
  border-top: 1px solid #2a2e35;
  padding-top: 8px;
}

.roster-slot {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 11px;
  min-width: 0;
}

.roster-role {
  color: #6a7280;
  font-size: 10px;
  font-weight: 700;
  flex: 0 0 auto;
}

.roster-player {
  color: #e8e8e8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roster-slot--coach {
  grid-column: 1 / -1;
}

.roster-slot--coach .roster-player {
  color: #9aa0ab;
}

.roster-slot--override {
  grid-column: 1 / -1;
}

.roster-slot--override .roster-role {
  color: #4a7d9a;
}

.roster-slot--override .roster-player {
  color: #7acfff;
}

.team-select-row {
  align-items: end;
}

.swapTeamsBtn {
  flex: 0 0 32px;
  align-self: center;
  font-size: 16px;
  line-height: 1;
  padding: 6px;
}

.preselectHint {
  font-size: 11px;
  color: #6a7280;
  margin: -4px 0 0;
}

.live-team-row {
  gap: 6px;
}

.live-team-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #14161a;
  border: 1px solid #2a2e35;
  border-radius: 4px;
  padding: 4px 7px;
}

.live-team-label {
  font-size: 10px;
  color: #6a7280;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.live-team-value {
  font-size: 12px;
  color: #e8e8e8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-team-value.is-empty {
  color: #6a7280;
  font-style: italic;
}

.slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 16px;
}

.slot {
  background: #1d2025;
  border: 1px solid #2a2e35;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slot-title {
  margin: 0 0 4px;
  font-size: 14px;
  color: #9aa0ab;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.slot-title-name {
  display: flex;
  align-items: baseline;
  /* Shrinks (with ellipsis) before ever letting the live/lock badges get
     pushed off or overlapped — name and status badges each keep their own
     space instead of competing for the same line. */
  flex: 1 1 auto;
  min-width: 60px;
  overflow: hidden;
}

.slot-title-prefix {
  flex: 0 0 auto;
  white-space: nowrap;
}

.slot-title-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.slot-title .slotName {
  all: unset;
  font-size: inherit;
  color: inherit;
  font-weight: inherit;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid transparent;
  cursor: default;
}

.slot-title .slotName:hover {
  border-bottom-color: #444;
  cursor: text;
}

.slot-title .slotName:focus {
  border-bottom-color: #9aa0ab;
  outline: none;
  cursor: text;
}

.liveIndicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  background: #4a1212;
  border: 1px solid #a02020;
  color: #ff6b6b;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 8px 3px 6px;
  border-radius: 999px;
}

.liveIndicator[hidden] {
  display: none;
}

.liveIndicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff4d4d;
  box-shadow: 0 0 0 0 rgba(255, 77, 77, 0.6);
  animation: live-dot-pulse 1.3s ease-in-out infinite;
}

@keyframes live-dot-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0.55); }
  70% { box-shadow: 0 0 0 6px rgba(255, 77, 77, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0); }
}

/* Live cue: a soft pulsing red glow behind the card + an animated accent
   strip along the top edge — deliberately not the border/outline treatment,
   since that's already used for the locked state. */
.slot {
  position: relative;
}

.slot.slot--live {
  background: linear-gradient(180deg, rgba(160, 32, 32, 0.16) 0%, #1d2025 70px);
  animation: slot-live-glow 2.2s ease-in-out infinite;
}

.slot.slot--live::before {
  content: "";
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, transparent, #ff4d4d, transparent);
  animation: slot-live-strip 2.2s ease-in-out infinite;
}

@keyframes slot-live-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(160, 32, 32, 0); }
  50% { box-shadow: 0 0 24px 0 rgba(160, 32, 32, 0.25); }
}

@keyframes slot-live-strip {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.lockBtn {
  flex: 0 0 auto;
  background: #2a2e35;
  border: 1px solid #2a2e35;
  border-radius: 4px;
  color: #9aa0ab;
  font-size: 11px;
  padding: 4px 9px;
  cursor: pointer;
  white-space: nowrap;
}

.lockBtn:hover {
  background: #383e48;
  color: #e8e8e8;
}

.lockBtn.active {
  background: #4a1f1f;
  border-color: #7a3030;
  color: #ff8585;
}

.lockBtn.active:hover {
  background: #5c2626;
}

.slot.slot--locked {
  border-color: #7a3030;
}

.slot.slot--locked .row:not(.live-team-row),
.slot.slot--locked .compact-row,
.slot.slot--locked .stepper-group,
.slot.slot--locked .slotName {
  opacity: 0.55;
  pointer-events: none;
}

.slot.slot--locked input:not(.lockBtn),
.slot.slot--locked select,
.slot.slot--locked .stepper-btn,
.slot.slot--locked .swapTeamsBtn {
  cursor: not-allowed;
}

.slot label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: #9aa0ab;
  flex: 1;
  min-width: 0;
}

.slot input, .slot select {
  width: 100%;
  min-width: 0;
  background: #14161a;
  border: 1px solid #2a2e35;
  border-radius: 4px;
  color: #e8e8e8;
  padding: 4px 7px;
  font-size: 12px;
}

.slot .row {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.game-field {
  flex: 0 0 60px !important;
}

.bestof-field {
  flex: 0 0 72px !important;
}

.compact-row {
  align-items: flex-end;
}

.stepper-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.stepper-label {
  font-size: 11px;
  color: #9aa0ab;
}

.stepper {
  display: flex;
  align-items: stretch;
  min-width: 0;
}

.stepper-btn {
  flex: 0 0 28px;
  background: #2a2e35;
  border: 1px solid #2a2e35;
  color: #e8e8e8;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}

.stepper-btn:hover {
  background: #383e48;
}

.stepper-btn:active {
  background: #454c58;
}

.stepper-btn:first-child {
  border-radius: 4px 0 0 4px;
  border-right: none;
}

.stepper-btn:last-child {
  border-radius: 0 4px 4px 0;
  border-left: none;
}

.stepper input {
  width: 100%;
  min-width: 0;
  flex: 1;
  text-align: center;
  background: #14161a;
  border: 1px solid #2a2e35;
  border-radius: 0;
  color: #e8e8e8;
  padding: 4px;
  font-size: 12px;
}

.stepper-group--warning .stepper {
  outline: 2px solid #e6b800;
  border-radius: 4px;
}

.stepper-group--warning .stepper-btn,
.stepper-group--warning .stepper input {
  border-color: #e6b800;
}

.scoreWarning {
  display: none;
  margin: 4px 0 0;
  font-size: 11px;
  color: #e6b800;
}

.scoreWarning.visible {
  display: block;
}

.toggle-label {
  flex-direction: row !important;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  width: auto;
  min-width: 0;
  flex: 0 0 auto;
  cursor: pointer;
}

.fearless-toggle {
  flex: 1 !important;
  justify-content: flex-end;
  padding-bottom: 4px;
}

.slot-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

.overlayLink {
  font-size: 11px;
  color: #6a7280;
  word-break: break-all;
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overlayLink a {
  color: #7aa2ff;
}

.previewToggleBtn {
  flex-shrink: 0;
  background: #2a2e35;
  border: 1px solid #2a2e35;
  border-radius: 4px;
  color: #9aa0ab;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
}

.previewToggleBtn:hover {
  background: #383e48;
  color: #e8e8e8;
}

.previewToggleBtn.active {
  background: #1f3a4a;
  border-color: #2e6080;
  color: #7acfff;
}

/* Preview iframe scaled to fit its own box width, rendered at 1920×1080.
   --preview-scale is computed from .slot-preview's own clientWidth (see
   dashboard.js), so the scaled viewport always matches this box exactly
   regardless of viewport/screen size. */
.slot-preview {
  display: none;
  width: 100%;
  overflow: hidden;
  border-radius: 4px;
  border: 1px solid #2a2e35;
}

.slot.preview-open .slot-preview {
  display: block;
}

.slot-preview-viewport {
  width: 1920px;
  height: 1080px;
  transform-origin: top left;
  /* scale is applied inline via JS resize observer / CSS variable */
  transform: scale(var(--preview-scale, 0.15));
}

.slot-preview-frame {
  width: 1920px;
  height: 1080px;
  border: none;
  display: block;
}

/* ── New team modal ─────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: #1d2025;
  border: 1px solid #2a2e35;
  border-radius: 10px;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #2a2e35;
}

.modal-header h3 {
  margin: 0;
  font-size: 15px;
}

.modal-close {
  background: transparent;
  border: none;
  color: #9aa0ab;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.modal-close:hover {
  color: #e8e8e8;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}

.modal-body .row {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #9aa0ab;
  flex: 1;
  min-width: 0;
}

.modal-body input {
  width: 100%;
  min-width: 0;
  background: #14161a;
  border: 1px solid #2a2e35;
  border-radius: 4px;
  color: #e8e8e8;
  padding: 6px 8px;
  font-size: 13px;
}

.modal-body input:invalid {
  border-color: #2a2e35;
}

.optional-tag {
  color: #545a64;
  font-weight: 400;
  text-transform: none;
  font-size: 10px;
}

.tricode-field {
  flex: 0 0 80px;
}

.logo-url-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.logo-url-row input {
  flex: 1;
  min-width: 0;
}

.file-pick-btn {
  flex-shrink: 0;
  cursor: pointer;
  padding: 6px 10px;
  background: #2a2e35;
  border: 1px solid #2a2e35;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  user-select: none;
  color: #e8e8e8;
}

.file-pick-btn:hover {
  background: #383e48;
}

.modal-logo-preview {
  width: 56px;
  height: 56px;
  object-fit: contain;
  align-self: flex-start;
  background: #14161a;
  border: 1px solid #2a2e35;
  border-radius: 6px;
  padding: 4px;
}

.score-field {
  max-width: 160px;
}

.modal-error {
  background: #4a1f1f;
  color: #ff8585;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 12px;
  margin: 0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.modal-footer button {
  background: #2a2e35;
  border: 1px solid #2a2e35;
  border-radius: 4px;
  color: #e8e8e8;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}

.modal-footer button:hover {
  background: #383e48;
}

#newTeamSubmitBtn {
  background: #1f3a4a;
  border-color: #2e6080;
  color: #7acfff;
}

#newTeamSubmitBtn:hover {
  background: #234b63;
}

#newTeamSubmitBtn:disabled {
  opacity: 0.6;
  cursor: default;
}
