:root {
  color-scheme: dark;
  --bg: #16191d;
  --panel: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.18);
  --text: #fffafa;
  --muted: #cfd2d6;
  --red: #f04450;
  --red-dark: #8b101b;
  --blue: #40a2ff;
  --green: #59c47a;
  --amber: #ffc15f;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(135deg, #241114 0%, #171a20 44%, #101216 100%);
  background-size: 48px 48px, auto;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.scoreboard {
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1.25fr) auto minmax(0, 0.9fr);
  gap: clamp(14px, 2vh, 24px);
  padding: clamp(22px, 3vw, 54px);
}

.topbar,
.details,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.topbar span,
.team span,
.details span,
.section-head span,
.report-row span,
.report-row em {
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.7rem);
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 0.95;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin-top: 6px;
  font-size: clamp(3rem, 6vw, 6.8rem);
}

.clock {
  min-width: 280px;
  text-align: right;
}

.clock strong {
  display: block;
  font-size: clamp(2.2rem, 5vw, 5.5rem);
  line-height: 0.9;
}

.clock span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: clamp(0.8rem, 1.2vw, 1.2rem);
}

.teams {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(140px, 12vw, 230px) minmax(0, 1fr);
  gap: clamp(16px, 2vw, 30px);
  align-items: stretch;
  min-height: 0;
}

.team,
.middle,
.details > div,
.report {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
}

.team {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  padding: clamp(20px, 2.4vw, 34px);
  overflow: hidden;
}

.team.home {
  border-color: rgba(240, 68, 80, 0.42);
}

.team.away {
  border-color: rgba(64, 162, 255, 0.42);
}

.team h2 {
  align-self: start;
  font-size: clamp(2rem, 3vw, 3.75rem);
  overflow-wrap: anywhere;
}

.team strong {
  align-self: end;
  font-size: clamp(6.5rem, 11.4vw, 12.8rem);
  line-height: 0.82;
  font-weight: 1000;
  text-shadow: 0 10px 38px rgba(0, 0, 0, 0.52);
}

.home strong {
  color: var(--red);
}

.away strong {
  color: var(--blue);
}

.middle {
  display: grid;
  place-items: center;
  align-content: center;
  padding: 18px;
}

.middle b {
  font-size: clamp(4rem, 8vw, 9rem);
  line-height: 0.8;
}

.middle small {
  border: 1px solid rgba(89, 196, 122, 0.52);
  border-radius: 999px;
  color: var(--green);
  padding: 8px 16px;
  font-size: clamp(0.9rem, 1.2vw, 1.25rem);
  font-weight: 950;
}

.details {
  align-items: stretch;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.7fr);
}

.details > div {
  min-width: 0;
  padding: clamp(14px, 1.6vw, 22px);
}

.details strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.25rem, 2vw, 2.3rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.report {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: clamp(16px, 2vw, 26px);
  overflow: hidden;
}

.section-head {
  margin-bottom: 12px;
}

.section-head h2 {
  font-size: clamp(1.8rem, 3vw, 3.4rem);
}

.report-rows {
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 10px;
  overflow: hidden;
}

.report-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 130px;
  gap: 16px;
  align-items: center;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  padding: 8px 12px;
}

.report-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(1.15rem, 1.65vw, 1.95rem);
}

.report-row span,
.report-row em {
  white-space: nowrap;
}

.report-row b {
  color: #fff;
  font-size: 1.15em;
}

.report-row.done em {
  color: var(--green);
}

.report-row.open em {
  color: var(--amber);
}

.error .clock span {
  color: var(--amber);
}

.setup-page {
  overflow: auto;
}

.setup-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.setup-panel {
  width: min(760px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: clamp(22px, 4vw, 42px);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
}

.setup-kicker,
.setup-status,
.tv-link,
.source-form label {
  color: var(--muted);
  font-weight: 900;
}

.setup-panel h1 {
  font-size: clamp(2.4rem, 6vw, 5rem);
  margin-bottom: 22px;
}

.source-form {
  display: grid;
  gap: 14px;
}

.source-form label {
  display: grid;
  gap: 8px;
}

.source-form input,
.source-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
}

.source-form textarea {
  resize: vertical;
}

.primary,
.tv-link {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff;
  font: inherit;
  font-weight: 950;
  cursor: pointer;
}

.tv-link {
  display: inline-flex;
  align-items: center;
  margin-top: 16px;
  text-decoration: none;
}

.setup-status.ok {
  color: var(--green);
}

.setup-status.error {
  color: var(--amber);
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .scoreboard {
    height: auto;
    min-height: 100vh;
    grid-template-rows: auto auto auto auto;
  }

  .topbar,
  .details {
    flex-direction: column;
    align-items: stretch;
  }

  .clock {
    text-align: left;
  }

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

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

  .report-row {
    grid-template-columns: 1fr;
  }

  .report-row strong {
    white-space: normal;
  }
}
