:root {
  color-scheme: dark;
  --bg: #0a0b0f;
  --bg-elev: #12141c;
  --bg-soft: #181b26;
  --bg-hover: #1e2230;
  --line: rgba(255, 255, 255, 0.06);
  --line-mid: rgba(255, 255, 255, 0.1);
  --text: #f2f0eb;
  --muted: #9aa1b2;
  --faint: #6f7689;
  --accent: #e8b40a;
  --accent-hi: #f5c84a;
  --accent-dim: rgba(232, 180, 10, 0.14);
  --accent-line: rgba(232, 180, 10, 0.4);
  --ok: #3ecf8e;
  --ok-dim: rgba(62, 207, 142, 0.16);
  --err: #ff6b7a;
  --err-dim: rgba(255, 107, 122, 0.12);
  --font: "Poppins", sans-serif;
  --pad: clamp(14px, 2vw, 28px);
  --gap: clamp(12px, 1.5vw, 18px);
  --rail: clamp(320px, 30vw, 420px);
  --r: 12px;
  --r-lg: 16px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100dvh;
  color: var(--text);
  font-family: var(--font);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0.01em;
  background:
    radial-gradient(ellipse 80% 50% at 0% 0%, rgba(232, 180, 10, 0.07), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(80, 100, 160, 0.06), transparent 50%),
    linear-gradient(180deg, #0e1016 0%, var(--bg) 45%, #07080c 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font-family: var(--font);
}

.app {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: var(--pad);
  display: grid;
  gap: var(--gap);
  min-height: 100dvh;
  grid-template-rows: auto auto auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 2px;
}

.topbar__brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.topbar__logo {
  font-weight: 800;
  font-size: clamp(1.75rem, 3.4vw, 2.15rem);
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--accent);
}

.topbar__tag {
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--faint);
  padding-bottom: 2px;
}

.topbar__aside {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-mid);
  background: rgba(255, 255, 255, 0.03);
}

.status__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-dim);
  flex-shrink: 0;
}

.status.is-loading .status__dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  animation: pulse 1s var(--ease) infinite;
}

.status.is-error .status__dot {
  background: var(--err);
  box-shadow: 0 0 0 3px var(--err-dim);
  animation: none;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.status__text {
  font-weight: 500;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.btn {
  appearance: none;
  border: 1px solid var(--line-mid);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 9px;
  padding: 0 16px;
  height: 40px;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
  transition:
    border-color 0.18s var(--ease),
    background 0.18s var(--ease),
    color 0.18s var(--ease);
}

.btn:hover:not(:disabled) {
  border-color: var(--accent-line);
  background: var(--accent-dim);
  color: var(--accent-hi);
}

.btn:disabled {
  opacity: 0.4;
  cursor: wait;
}

.btn--soft {
  background: transparent;
  height: 38px;
  padding: 0 14px;
}

.btn.ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, var(--line));
  background: var(--ok-dim);
}

.btn:focus-visible,
.sports__btn:focus-visible,
.match:focus-visible,
.export__row input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sports {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 6px;
  margin: 0 calc(var(--pad) * -0.25);
  padding-inline: calc(var(--pad) * 0.25);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.sports::-webkit-scrollbar {
  display: none;
}

.sports__btn {
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 500;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition:
    background 0.18s var(--ease),
    color 0.18s var(--ease),
    border-color 0.18s var(--ease);
}

.sports__btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.sports__btn.is-active {
  background: var(--accent-dim);
  border-color: var(--accent-line);
  color: var(--accent-hi);
  font-weight: 600;
}

.banner {
  margin: 0;
  padding: 12px 16px;
  border-radius: var(--r);
  background: var(--err-dim);
  border: 1px solid color-mix(in srgb, var(--err) 28%, transparent);
  color: #ffb4bd;
  font-weight: 500;
  font-size: 0.95rem;
}

.workspace {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: var(--gap);
  align-items: stretch;
  min-height: 0;
}

.rail {
  display: flex;
  flex-direction: column;
  height: 0;
  min-height: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.rail__head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.015);
}

.rail__label {
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}

.matches {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

.matches__empty {
  padding: 40px 16px;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.95rem;
  text-align: center;
  line-height: 1.5;
}

.match {
  width: 100%;
  appearance: none;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 13px 14px 13px 16px;
  cursor: pointer;
  display: grid;
  gap: 5px;
  position: relative;
  transition: background 0.15s var(--ease);
}

.match::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 13px;
  bottom: 13px;
  width: 2px;
  border-radius: 2px;
  background: transparent;
  transition: background 0.15s var(--ease);
}

.match:hover:not(:disabled) {
  background: var(--bg-hover);
}

.match.is-active {
  background: var(--accent-dim);
}

.match.is-active::before {
  background: var(--accent);
}

.match:disabled {
  opacity: 0.55;
  cursor: wait;
}

.match__title {
  font-weight: 600;
  font-size: 0.98rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  color: var(--text);
}

.match.is-active .match__title {
  color: var(--accent-hi);
}

.match__meta {
  font-weight: 400;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.stage {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.stage__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 40px;
}

.stage__title {
  margin: 0;
  font-weight: 600;
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  letter-spacing: -0.025em;
  line-height: 1.25;
  min-width: 0;
  overflow-wrap: anywhere;
}

.timing {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.timing__item {
  display: grid;
  gap: 3px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  min-width: 100px;
}

.timing__k {
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.timing__v {
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.timing__v.is-live {
  color: var(--accent-hi);
}

.timing__v.is-done {
  color: var(--ok);
}

.stage__body {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.screen {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-bottom: 1px solid var(--line);
}

.screen__idle {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 55% 45% at 50% 42%, rgba(232, 180, 10, 0.1), transparent 70%),
    linear-gradient(160deg, #151821 0%, #08090d 100%);
}

.screen__idle-brand {
  margin: 0;
  font-weight: 800;
  font-size: clamp(2rem, 6vw, 3.2rem);
  letter-spacing: -0.045em;
  color: var(--accent);
  line-height: 1;
}

.screen__idle-copy {
  margin: 0;
  max-width: 32ch;
  justify-self: center;
  font-weight: 400;
  font-size: 1.02rem;
  color: var(--muted);
}

.screen__video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.screen.is-active .screen__idle {
  display: none;
}

.exports {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  padding: 16px 18px 18px;
  background: rgba(0, 0, 0, 0.18);
}

.export {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.export__k {
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.export__row {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.export__row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: #b8becc;
  font-weight: 400;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  line-height: 1.4;
  padding: 10px 12px;
  height: 38px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.export__row input:hover {
  border-color: var(--line-mid);
}

@media (max-width: 1100px) {
  :root {
    --rail: clamp(280px, 32vw, 360px);
  }
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(240px, 42vh);
  }

  .stage {
    order: -1;
  }

  .rail {
    height: auto;
    max-height: 42vh;
  }

  .stage__bar {
    align-items: flex-start;
  }

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

@media (max-width: 640px) {
  :root {
    --pad: 12px;
    --gap: 10px;
  }

  .app {
    gap: 10px;
  }

  .topbar {
    gap: 12px;
  }

  .topbar__aside {
    gap: 8px;
  }

  .status {
    height: 38px;
    padding: 0 12px 0 10px;
  }

  .btn {
    height: 38px;
    padding: 0 14px;
  }

  .stage__bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .timing {
    width: 100%;
  }

  .timing__item {
    flex: 1;
    min-width: 0;
  }

  .workspace {
    grid-template-rows: auto minmax(220px, 46vh);
  }

  .rail {
    max-height: 46vh;
  }

  .exports {
    padding: 14px;
  }

  .export__row .btn {
    flex-shrink: 0;
  }
}

@media (max-width: 420px) {
  .topbar__tag {
    display: none;
  }

  .status__text {
    font-size: 0.84rem;
  }

  .export__row {
    flex-wrap: wrap;
  }

  .export__row input {
    flex: 1 1 100%;
  }

  .export__row .btn {
    width: 100%;
  }
}
