/* =========
   Base
   ========= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #020617; /* very dark */
  color: #e5e7eb;      /* light gray text */
}

a {
  color: #38bdf8;      /* cyan */
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

/* Containers */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

/* =========
   Site Header / Footer
   ========= */
.site-header {
  background: #020617;
  border-bottom: 1px solid #1f2937;
  color: #f9fafb;
  padding: 0.75rem 0;
  margin-bottom: 1.5rem;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-header h1 {
  font-size: 1.4rem;
  margin: 0;
}

.site-header h1 a {
  color: #f9fafb;
  text-decoration: none;
}

.site-header nav a {
  color: #e5e7eb;
  margin-left: 1rem;
  font-size: 0.95rem;
}

.site-header nav a:hover {
  color: #ffffff;
  text-decoration: underline;
}

.site-footer {
  border-top: 1px solid #1f2937;
  padding: 1rem 0;
  text-align: center;
  font-size: 0.85rem;
  color: #9ca3af;
  background: #020617;
}

/* =========
   Typography / Layout
   ========= */
main h2 {
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}

main h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

p {
  line-height: 1.5;
}

/* Lists */
main ul {
  padding-left: 1.2rem;
}

/* =========
   Cards / Panels
   ========= */
main {
  background: #020617;
}

section {
  background: #020617;
}

/* =========
   Forms
   ========= */
form {
  display: grid;
  gap: 0.75rem;
  max-width: 500px;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 0.95rem;
  gap: 0.25rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="date"],
input[type="url"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
  border: 1px solid #4b5563;
  font: inherit;
  background: #020617;
  color: #e5e7eb;
}

input::placeholder,
textarea::placeholder {
  color: #6b7280;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #38bdf8;
  outline-offset: 1px;
  border-color: #38bdf8;
}

button {
  padding: 0.5rem 1rem;
  border-radius: 4px;
  border: none;
  background: #2563eb;
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
  font: inherit;
}

button:hover {
  background: #1d4ed8;
}

/* Fieldset */
fieldset {
  border: 1px solid #4b5563;
  border-radius: 4px;
  padding: 0.75rem 1rem;
}

legend {
  padding: 0 0.25rem;
  font-size: 0.9rem;
  font-weight: 600;
}

fieldset label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

/* Inline form (for event selector) */
.admin-form.inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: flex-end;
}

/* Messages */
.error {
  color: #fecaca;
  background: #7f1d1d;
  border: 1px solid #b91c1c;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.9rem;
  max-width: 500px;
}

.info {
  color: #bbf7d0;
  background: #064e3b;
  border: 1px solid #16a34a;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.9rem;
  max-width: 500px;
}

/* =========
   Tables
   ========= */
table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

th, td {
  border: 1px solid #374151;
  padding: 0.4rem 0.5rem;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #020617;
  color: #e5e7eb;
  font-weight: 600;
}

tr:nth-child(even) {
  background: #020617;
}

tr:nth-child(odd) {
  background: #020617;
}

.admin-table input[type="number"],
.admin-table input[type="text"],
.admin-table input[type="datetime-local"],
.admin-table select {
  font-size: 0.85rem;
  padding: 0.25rem 0.35rem;
}

/* =========
   Bracket Layout
   ========= */
.bracket-wrapper {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.bracket-round {
  min-width: 220px;
}

.bracket-round h3 {
  text-align: center;
  margin-bottom: 0.5rem;
  color: #e5e7eb;
}

.bracket-game {
  border: 1px solid #1f2937;
  border-radius: 6px;
  background: #020617;
  padding: 0.4rem 0.5rem;
  margin-bottom: 0.6rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.6);
}

.bracket-game .team {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

.bracket-game .team + .team {
  margin-top: 0.1rem;
}

.bracket-game .name {
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bracket-game .score {
  font-weight: 600;
  min-width: 1.5rem;
  text-align: right;
}

.bracket-game .meta {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: #9ca3af;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* =========
   Admin Layout
   ========= */
body.admin {
  background: #020617;
}

.admin-header {
  background: #020617;
  border-bottom: 1px solid #1f2937;
  color: #f9fafb;
  padding: 0.75rem 0;
  margin-bottom: 1rem;
}

.admin-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.admin-header h1 {
  font-size: 1.3rem;
  margin: 0;
}

.admin-header nav a {
  color: #e5e7eb;
  margin-left: 0.75rem;
  font-size: 0.9rem;
}

.admin-header nav a:hover {
  color: #ffffff;
  text-decoration: underline;
}

/* Admin login */
body.admin-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #020617;
}

.login-box {
  background: #020617;
  border: 1px solid #1f2937;
  padding: 1.5rem 1.75rem;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.9);
  width: 100%;
  max-width: 360px;
}

.login-box h1 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.3rem;
}

.login-box form {
  max-width: none;
}

/* =========
   Utility / Cards
   ========= */
.admin-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.admin-stats .card {
  background: #020617;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  min-width: 160px;
  border: 1px solid #1f2937;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.9);
}

.admin-stats .card h3 {
  margin: 0 0 0.2rem 0;
  font-size: 0.9rem;
  color: #9ca3af;
}

.admin-stats .card p {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
}

/* =========
   Responsive
   ========= */
@media (max-width: 768px) {
  .site-header .container,
  .admin-header .container {
    flex-direction: column;
    align-items: flex-start;
  }

  .site-header nav a,
  .admin-header nav a {
    margin-left: 0;
    margin-right: 0.75rem;
  }

  main.container {
    padding: 0 0.75rem 1.5rem;
  }

  table {
    font-size: 0.8rem;
  }

  th, td {
    padding: 0.3rem 0.35rem;
  }

  .admin-stats {
    flex-direction: column;
  }
}

/* =========
   Calendar
   ========= */

/* Top month nav */
.calendar-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 550px;
  margin: 0 0 0.75rem 0;
  font-size: 0.9rem;
}

.calendar-nav span {
  font-weight: 600;
}

.calendar-nav a {
  font-size: 0.9rem;
}

/* Desktop calendar container */
.calendar {
  max-width: 800px;
  margin-top: 0.75rem;
}

/* Header row: days of week */
.calendar-header-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.3rem;
  font-size: 0.8rem;
  text-align: center;
  margin-bottom: 0.35rem;
  color: #9ca3af;
}

.calendar-header-row > div {
  padding: 0.25rem 0;
}

/* Main grid: uniform rows on desktop */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.3rem;
  grid-auto-rows: 90px; /* fixed height per row on desktop */
}

/* Individual day cells */
.calendar-day {
  height: 100%;
  border-radius: 8px;
  border: 1px solid #1f2937;
  background: #020617;
  padding: 0.3rem 0.35rem;
  font-size: 0.8rem;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto; /* scroll inside the cell if many events */
}

.calendar-day.empty {
  border: none;
  background: transparent;
}

.calendar-day-number {
  font-size: 0.9rem;
  font-weight: 600;
  color: #9ca3af;
  margin-bottom: 0.2rem;
}

.calendar-day.has-event {
  background: #020617;
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.35);
}

/* Event list inside each day */
.calendar-events {
  list-style: none;
  padding-left: 0;
  margin: 0;
  margin-top: 0.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.calendar-events li {
  margin: 0;
}

.calendar-events a {
  display: block;
  font-size: 0.75rem;
  color: #f9fafb;
  padding: 0.12rem 0.3rem;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(56, 189, 248, 0.16); /* default pill bg */
}

.calendar-events a:hover {
  background: rgba(56, 189, 248, 0.28);
  text-decoration: none;
}

/* Note under calendar */
.calendar-note {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: #9ca3af;
}

/* Legend */
.calendar-legend {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #9ca3af;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
}

.calendar-legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.calendar-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

/* Mobile list view (hidden on desktop; shown via media query) */
.calendar-list {
  display: none;          /* show only on mobile */
  margin-top: 0.75rem;
  max-width: 800px;
}

.calendar-list-day {
  border-radius: 8px;
  border: 1px solid #1f2937;
  background: #020617;
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.5rem;
}

.calendar-list-date {
  font-size: 0.9rem;
  font-weight: 600;
  color: #e5e7eb;
  margin-bottom: 0.25rem;
}

/* Division color coding (events + legend) */
.event-7u a,
.legend-7u {
  background: rgba(148, 163, 184, 0.35);
  border-left: 3px solid #9ca3af;
}

.event-8u a,
.legend-8u {
  background: rgba(56, 189, 248, 0.25);
  border-left: 3px solid #38bdf8;
}

.event-9u a,
.legend-9u {
  background: rgba(34, 197, 94, 0.25);
  border-left: 3px solid #22c55e;
}

.event-10u a,
.legend-10u {
  background: rgba(249, 115, 22, 0.25);
  border-left: 3px solid #f97316;
}

.event-11u a,
.legend-11u {
  background: rgba(168, 85, 247, 0.25);
  border-left: 3px solid #a855f7;
}

.event-12u a,
.legend-12u {
  background: rgba(248, 113, 113, 0.25);
  border-left: 3px solid #f97373;
}

/* =========
   Mobile tweaks
   ========= */
@media (max-width: 768px) {
  /* Hide grid calendar, show list */
  .calendar {
    max-width: 100%;
    display: none;
  }

  .calendar-list {
    display: block;
  }

  .calendar-day {
    min-height: 70px;
    height: auto;
    padding: 0.25rem 0.3rem;
    overflow: visible;
  }

  .calendar-day-number {
    font-size: 0.85rem;
  }

  .calendar-events a {
    font-size: 0.7rem;
    padding: 0.1rem 0.25rem;
  }

  .calendar-legend {
    font-size: 0.8rem;
  }
}
