:root {
  color-scheme: dark;
  --page: #070912;
  --panel: #101522;
  --panel-raised: #151c2c;
  --line: #263149;
  --text: #f7f9ff;
  --muted: #9ca8bd;
  --gold: #f2c94c;
  --green: #49dc86;
  --red: #ff5f6d;
  --home: #55a6ff;
  --home-soft: rgba(85, 166, 255, 0.12);
  --away: #ff727d;
  --away-soft: rgba(255, 114, 125, 0.12);
  --radius: 14px;
  font-family: Bahnschrift, "Arial Narrow", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 1024px;
  background: var(--page);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -20%, rgba(85, 166, 255, 0.15), transparent 32%),
    radial-gradient(circle at 88% -20%, rgba(255, 114, 125, 0.13), transparent 32%),
    var(--page);
}

button,
input,
select {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 9, 18, 0.94);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(16px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 23px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h2 {
  font-size: 20px;
}

.eyebrow,
.section-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.topbar-actions,
.clock-actions,
.possession-actions,
.button-row,
.media-buttons,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 185px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #667086;
}

.connection.online {
  border-color: rgba(73, 220, 134, 0.4);
  color: var(--green);
  background: rgba(73, 220, 134, 0.08);
}

.connection.online .connection-dot {
  background: var(--green);
  box-shadow: 0 0 12px rgba(73, 220, 134, 0.8);
}

.button,
.mini-button,
.effect-button,
.icon-button,
.text-button {
  border: 0;
  cursor: pointer;
}

.button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: white;
  font-weight: 800;
  letter-spacing: 0.02em;
  transition: transform 100ms ease, filter 150ms ease, border-color 150ms ease;
}

.button:hover,
.mini-button:hover,
.effect-button:hover {
  filter: brightness(1.15);
}

.button:active,
.mini-button:active,
.effect-button:active {
  transform: translateY(1px) scale(0.98);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button.compact {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 12px;
}

.button.primary {
  border-color: #3967b9;
  background: #234c91;
}

.button.secondary,
.settings-button {
  border-color: var(--line);
  background: #172033;
}

.button.success {
  min-width: 100px;
  border-color: rgba(73, 220, 134, 0.45);
  color: var(--green);
  background: rgba(73, 220, 134, 0.12);
}

.button.success.running {
  border-color: rgba(242, 201, 76, 0.5);
  color: var(--gold);
  background: rgba(242, 201, 76, 0.12);
}

.button.warning {
  border-color: rgba(242, 201, 76, 0.36);
  color: var(--gold);
  background: rgba(242, 201, 76, 0.09);
}

.button.danger {
  border-color: rgba(255, 95, 109, 0.42);
  color: #ff9ba3;
  background: rgba(255, 95, 109, 0.1);
}

.button.home-outline {
  border-color: rgba(85, 166, 255, 0.45);
  color: var(--home);
  background: var(--home-soft);
}

.button.away-outline {
  border-color: rgba(255, 114, 125, 0.45);
  color: var(--away);
  background: var(--away-soft);
}

main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
}

.panel,
.team-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(21, 28, 44, 0.97), rgba(12, 16, 28, 0.97));
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
}

.game-console {
  display: grid;
  grid-template-columns: 170px minmax(570px, 1fr) minmax(370px, 0.8fr) 130px;
  align-items: stretch;
  gap: 10px;
  padding: 10px;
}

.game-console > div {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(38, 49, 73, 0.78);
  border-radius: 10px;
  background: rgba(5, 8, 16, 0.33);
}

.period-control,
.clock-control,
.possession-control,
.match-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.period-control {
  flex-wrap: wrap;
}

.period-control strong {
  color: var(--gold);
  font-size: 38px;
  line-height: 1;
}

.period-name {
  color: var(--muted);
  font-size: 12px;
}

.clock-control {
  flex-wrap: wrap;
  justify-content: center;
}

.control-clock {
  min-width: 145px;
  color: var(--gold);
  font-family: Consolas, "Courier New", monospace;
  font-size: 40px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.control-clock.running {
  color: var(--green);
  text-shadow: 0 0 16px rgba(73, 220, 134, 0.32);
}

.control-clock.ending {
  color: var(--red);
}

.manual-clock {
  display: flex;
  align-items: center;
  gap: 6px;
}

.manual-clock label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
}

.manual-clock input {
  width: 48px;
  padding: 5px;
}

.possession-control {
  flex-wrap: wrap;
  justify-content: center;
}

.possession-current {
  min-width: 145px;
  color: var(--gold);
  font-size: 17px;
  font-weight: 900;
  text-align: center;
}

.match-actions {
  flex-direction: column;
  justify-content: center;
}

.match-actions .button {
  width: 100%;
}

.teams-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.team-card {
  min-width: 0;
  overflow: hidden;
}

.home-team {
  border-top: 3px solid var(--home);
}

.away-team {
  border-top: 3px solid var(--away);
}

.team-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
}

.team-heading label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.team-name-input {
  min-width: 0;
  flex: 1;
  padding: 5px 8px;
  border: 0;
  border-bottom: 2px solid var(--line);
  outline: 0;
  color: white;
  background: transparent;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.home-team .team-name-input:focus {
  border-color: var(--home);
}

.away-team .team-name-input:focus {
  border-color: var(--away);
}

.team-summary {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr 1.1fr;
  gap: 7px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.summary-block {
  display: flex;
  min-height: 130px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(38, 49, 73, 0.72);
  border-radius: 10px;
  background: rgba(4, 7, 14, 0.35);
}

.summary-value,
.team-foul-display {
  font-size: 41px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.home-team .summary-value,
.home-team .team-foul-display {
  color: var(--home);
}

.away-team .summary-value,
.away-team .team-foul-display {
  color: var(--away);
}

.team-foul-display.bonus-square {
  width: 43px;
  height: 43px;
  border-radius: 3px;
  color: transparent;
  background: #ff1f2f;
  box-shadow: 0 0 20px rgba(255, 31, 47, 0.75);
}

.mini-button {
  min-width: 31px;
  min-height: 30px;
  padding: 5px 7px;
  border: 1px solid #34415d;
  border-radius: 7px;
  color: white;
  background: #202b42;
  font-size: 12px;
  font-weight: 900;
}

.mini-button.negative {
  border-color: rgba(255, 95, 109, 0.33);
  color: #ff9ba3;
  background: rgba(255, 95, 109, 0.1);
}

.text-button {
  padding: 0;
  color: #b8c8e6;
  background: none;
  font-size: 10px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.score-warning,
.bonus-note,
.timeout-note,
.media-status,
.settings-help,
.file-status {
  min-height: 13px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
  text-align: center;
}

.score-warning {
  color: var(--gold);
}

.bonus-button {
  min-height: 27px;
  padding: 4px 8px;
  border-color: rgba(255, 95, 109, 0.35);
  color: #ff9ba3;
  background: rgba(255, 95, 109, 0.08);
  font-size: 10px;
}

.bonus-button.active {
  color: white;
  background: #cf1f32;
  box-shadow: 0 0 14px rgba(255, 31, 47, 0.4);
}

.bonus-button:disabled {
  opacity: 0.4;
}

.timeout-dots {
  display: flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.timeout-dot {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 2px solid #46526b;
  border-radius: 50%;
  color: #8f9ab0;
  font-size: 9px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.03);
}

.home-team .timeout-dot.active {
  border-color: var(--home);
  color: white;
  background: var(--home);
  box-shadow: 0 0 12px rgba(85, 166, 255, 0.4);
}

.away-team .timeout-dot.active {
  border-color: var(--away);
  color: white;
  background: var(--away);
  box-shadow: 0 0 12px rgba(255, 114, 125, 0.4);
}

.timeout-dot.lost {
  border-color: #72798a;
  color: #d4d7df;
  background: #4c5363;
}

.roster-heading,
.player-row {
  display: grid;
  grid-template-columns: 46px minmax(115px, 1fr) 220px 160px;
  align-items: center;
  gap: 6px;
}

.roster-heading {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.roster-heading span:nth-child(3),
.roster-heading span:nth-child(4) {
  text-align: center;
}

.roster {
  display: flex;
  flex-direction: column;
}

.player-row {
  min-height: 47px;
  padding: 5px 9px;
  border-bottom: 1px solid rgba(38, 49, 73, 0.58);
  transition: background 130ms ease, box-shadow 130ms ease;
}

.player-row:last-child {
  border-bottom: 0;
}

.player-row:hover {
  background: rgba(255, 255, 255, 0.025);
}

.home-team .player-row.selected {
  background: var(--home-soft);
  box-shadow: inset 3px 0 var(--home);
}

.away-team .player-row.selected {
  background: var(--away-soft);
  box-shadow: inset -3px 0 var(--away);
}

.player-input {
  width: 100%;
  min-width: 0;
  padding: 6px;
  border: 1px solid #303b52;
  border-radius: 6px;
  outline: 0;
  color: white;
  background: #0c111d;
  font-size: 13px;
  font-weight: 700;
}

.player-number {
  text-align: center;
}

.player-input:focus {
  border-color: #6d89bd;
}

.player-input.invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(255, 95, 109, 0.12);
}

.player-score-control,
.player-foul-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.player-stat {
  display: grid;
  min-width: 34px;
  height: 30px;
  place-items: center;
  border-radius: 6px;
  color: white;
  background: rgba(255, 255, 255, 0.07);
  font-size: 14px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.player-foul-control .player-stat.fifth {
  color: white;
  background: #d52334;
  box-shadow: 0 0 12px rgba(255, 31, 47, 0.5);
}

.player-action {
  min-width: 29px;
  min-height: 29px;
  padding: 3px;
  border: 1px solid #33405a;
  border-radius: 6px;
  color: #dfe8f8;
  background: #1b2539;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.player-action[data-player-score] {
  min-width: 38px;
  min-height: 36px;
  font-size: 14px;
}

.mini-button[data-team-score] {
  min-width: 42px;
  min-height: 36px;
  font-size: 14px;
}

.player-action.minus {
  color: #ff9ba3;
}

.media-panel {
  display: grid;
  grid-template-columns: 145px 1fr 230px;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
}

.media-buttons {
  justify-content: center;
}

.effect-button {
  min-height: 46px;
  padding: 9px 18px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 10px;
  color: white;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.effect-button.dunk {
  background: linear-gradient(135deg, #3b56ac, #21326f);
}

.effect-button.three {
  background: linear-gradient(135deg, #b57415, #6f430b);
}

.effect-button.highlight {
  background: linear-gradient(135deg, #6a3db6, #3c226a);
}

.effect-button.funny {
  background: linear-gradient(135deg, #2c8a6e, #175040);
}

.history-panel {
  padding: 10px 14px;
}

.history-panel summary {
  cursor: pointer;
  color: #c7d2e6;
  font-weight: 800;
}

#history-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 28px;
  margin: 10px 0 0;
  padding-left: 24px;
  color: var(--muted);
  font-size: 12px;
}

.hotkeys {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px 18px;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 11px;
}

kbd {
  display: inline-block;
  min-width: 24px;
  padding: 2px 5px;
  border: 1px solid #3d4962;
  border-bottom-width: 2px;
  border-radius: 4px;
  color: white;
  background: #1a2233;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 100;
  bottom: 22px;
  left: 50%;
  max-width: min(620px, 88vw);
  padding: 10px 18px;
  border: 1px solid #43506b;
  border-radius: 10px;
  opacity: 0;
  color: white;
  background: #1a2233;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  font-weight: 700;
  pointer-events: none;
  transform: translate(-50%, 15px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.settings-dialog {
  width: min(1160px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  padding: 0;
  overflow: auto;
  border: 1px solid #3b4965;
  border-radius: 16px;
  color: var(--text);
  background: #0f1522;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.7);
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(5px);
}

.settings-dialog form {
  padding: 18px;
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: white;
  background: #202a3e;
  font-size: 25px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.02);
}

legend {
  padding: 0 7px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

fieldset > label,
.video-setting-row label {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(120px, 0.65fr);
  align-items: center;
  gap: 9px;
  margin-bottom: 9px;
  color: #c5cede;
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid #34405a;
  border-radius: 7px;
  outline: none;
  color: white;
  background: #0b101b;
}

input:focus,
select:focus {
  border-color: #6480b4;
}

input[type="range"] {
  padding: 0;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.checkbox-label input {
  min-width: auto;
}

.video-settings {
  margin-top: 12px;
}

.video-setting-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr 155px;
  align-items: end;
  gap: 9px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(38, 49, 73, 0.65);
}

.video-setting-row:last-child {
  border-bottom: 0;
}

.video-setting-row label {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin: 0;
}

.file-label input {
  padding: 5px;
  font-size: 10px;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 15px;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(255, 95, 109, 0.42);
  border-radius: 10px;
  background: rgba(255, 95, 109, 0.08);
}

.danger-zone h3,
.danger-zone p {
  margin: 0;
}

.danger-zone h3 {
  color: #ff9ba3;
  font-size: 15px;
}

.danger-zone p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 1450px) {
  .game-console {
    grid-template-columns: 160px minmax(520px, 1fr) minmax(320px, 0.75fr);
  }

  .match-actions {
    grid-column: 1 / -1;
    flex-direction: row;
  }

  .match-actions .button {
    width: auto;
  }

  .roster-heading,
  .player-row {
    grid-template-columns: 42px minmax(95px, 1fr) 195px 145px;
  }

  .player-action {
    min-width: 25px;
  }

  .player-action[data-player-score] {
    min-width: 35px;
  }
}

@media (max-width: 1180px) {
  .teams-grid {
    grid-template-columns: 1fr;
  }

  .game-console {
    grid-template-columns: 160px 1fr;
  }

  .possession-control,
  .match-actions {
    grid-column: auto;
  }
}
