* {
  box-sizing: border-box;
}

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

body {
  font-family: Arial, sans-serif;
  text-align: center;
  margin: 0;
  padding: 0;
  background: #000;
  color: #fff;
  width: 100%;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

.navigation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  background-color: #202020;
}

.navigation a {
  color: #FFD700;
  text-decoration: none;
  margin: 0;
}

.navigation a:hover {
  color: #fff;
}

.page-shell {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 12px 40px;
}

.form-card,
.dashboard {
  width: 100%;
  max-width: 900px;
  margin: 20px auto;
  background: #fff;
  color: #000;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.form-card h1,
.dashboard h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 5vw, 42px);
}

.helper-text {
  margin: 0 0 18px;
  color: #555;
  line-height: 1.4;
}

.field-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin: 12px auto;
  max-width: 520px;
  text-align: left;
}

.field-group label {
  font-weight: bold;
}

.field-group input,
.field-group select,
.match-picker select {
  width: 100%;
  min-height: 46px;
  padding: 10px;
  border: 1px solid #bbb;
  border-radius: 8px;
  background: #fff;
}

.primary-button,
.secondary-button,
.danger-button,
.match-card button {
  min-height: 46px;
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
}

.primary-button {
  background: #007BFF;
  color: #fff;
  margin-top: 8px;
}

.primary-button:hover {
  background: #0056b3;
}

.secondary-button {
  background: #202020;
  color: #FFD700;
}

.danger-button {
  background: #b00020;
  color: #fff;
}

.dynamic-section {
  margin-top: 20px;
}

.hidden {
  display: none !important;
}

.team-input-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 16px;
}

.match-mode-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  max-width: 520px;
  margin: 16px auto 0;
}

.match-builder-card {
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 16px;
  background: #f7f7f7;
}

.match-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.vs-label {
  font-weight: bold;
}

.selected-matches {
  margin: 16px 0;
  display: grid;
  gap: 8px;
}

.selected-match-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  text-align: left;
}

.selected-match-row strong {
  word-break: break-word;
}

.dashboard {
  max-width: 1200px;
  background: transparent;
  color: #fff;
  box-shadow: none;
  padding: 0;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  text-align: left;
}

.dashboard .helper-text {
  color: #ccc;
}

.matches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.match-card {
  background: #fff;
  color: #000;
  border-radius: 14px;
  padding: 16px;
  text-align: center;
}

.match-title {
  font-weight: bold;
  font-size: 20px;
  margin-bottom: 12px;
  word-break: break-word;
}

.score-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 18px;
  margin-bottom: 12px;
}

.score-box {
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 10px;
}

.score-value {
  display: block;
  font-size: 34px;
  font-weight: bold;
  margin-top: 4px;
}

.score-adjust-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 10px;
}

.match-card .score-adjust-buttons button {
  min-height: 40px;
  padding: 8px;
  font-size: 14px;
}

.match-card .score-adjust-buttons .score-minus {
  background: #555;
}

.match-card .score-adjust-buttons .score-plus {
  background: #007BFF;
}

.timer-label {
  font-weight: bold;
  margin-top: 10px;
}

.timer-box {
  background: #000;
  color: #fff;
  padding: 14px;
  border-radius: 10px;
  font-size: clamp(30px, 8vw, 54px);
  font-weight: bold;
  margin: 8px 0 12px;
}

.break-timer {
  background: #0038a8;
}

.match-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.match-card button {
  width: 100%;
  background: #202020;
  color: #fff;
}

.match-card button.point-button {
  background: #007BFF;
}

.match-card button.reset-button {
  background: #555;
}

.match-card button.danger-action {
  background: #b00020;
}

@media (max-width: 700px) {
  .page-shell {
    padding: 12px 8px 28px;
  }

  .form-card {
    padding: 16px;
    margin: 12px auto;
  }

  .match-picker {
    grid-template-columns: 1fr;
  }

  .vs-label {
    display: none;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
  }

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

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


.match-card button.towel-button {
  background: #8a5a00;
}

.match-card button.swap-button {
  background: #2b6777;
}


.race-label {
  display: inline-block;
  font-size: 13px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #202020;
  color: #FFD700;
}

.add-time-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 8px;
  margin: 8px 0 12px;
}

.add-time-controls input {
  width: 100%;
  min-height: 42px;
  padding: 8px;
  border: 1px solid #bbb;
  border-radius: 8px;
}

.match-card button.add-time-button {
  background: #2b6777;
}

.match-card button.reopen-button {
  background: #00875a;
}

.match-card.match-complete {
  outline: 4px solid #FFD700;
}

.complete-banner {
  background: #FFD700;
  color: #000;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 12px;
  font-weight: bold;
}

.match-card button:disabled,
.add-time-controls input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 390px) {
  .add-time-controls {
    grid-template-columns: 1fr;
  }
}


#tournamentSetupFields {
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 12px;
  margin: 16px auto;
  max-width: 560px;
  background: #f7f7f7;
}

#tournamentSetupFields .field-group {
  margin-top: 10px;
  margin-bottom: 10px;
}

.team-input-grid select {
  margin-top: 8px;
}


#manualMatchDivision {
  width: 100%;
  min-height: 46px;
  padding: 10px;
  border: 1px solid #bbb;
  border-radius: 8px;
  background: #fff;
}


.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.event-meta span {
  display: inline-block;
  background: #202020;
  color: #FFD700;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: bold;
}

@media (max-width: 700px) {
  .event-meta {
    justify-content: center;
  }
}
