:root {
  --court: #1a3d2e;
  --court-light: #2d5a45;
  --sand: #e8dcc8;
  --accent-1: #ff6b35;
  --accent-2: #4ecdc4;
  --text: #f5f2eb;
  --muted: rgba(245, 242, 235, 0.65);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: clamp(14px, 2.5vw, 18px);
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "DM Sans", system-ui, sans-serif;
  background: radial-gradient(ellipse 120% 80% at 50% 0%, var(--court-light), var(--court) 55%, #0f2419);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.camera-dock {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 50;
  max-width: min(18rem, 42vw);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.camera-dock[hidden] {
  display: none !important;
}

.camera-dock__inner {
  display: flex;
  flex-direction: column;
}

.camera-dock__video {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: #0a0a0a;
}

.camera-dock__bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.65rem;
  background: rgba(0, 0, 0, 0.55);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.camera-dock__rec {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #ff3b3b;
  box-shadow: 0 0 10px rgba(255, 59, 59, 0.6);
  animation: recPulse 1.2s ease-in-out infinite;
}

@keyframes recPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.camera-dock__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
}

.camera-dock__keys {
  margin: 0;
  padding: 0.35rem 0.65rem 0.55rem;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.35;
}

.camera-dock__keys kbd {
  font-size: 0.65rem;
}

.camera-toast {
  position: fixed;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(24rem, 92vw);
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: rgba(15, 36, 25, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.85rem;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.camera-toast[hidden] {
  display: none !important;
}

/* Vista cámara IP (puerto 8080), esquina superior derecha */
.top-preview-dock {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 44;
  width: min(420px, 92vw);
  border-radius: 12px;
  overflow: hidden;
  background: #0b57d0;
  border: 2px solid #4f8df0;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), 0 0 0 2px rgba(79, 141, 240, 0.3);
  padding: 0.45rem;
}

.top-preview-dock video {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(320px, 38vh);
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #0a0a0a;
  border-radius: 8px;
}

.top-preview-dock iframe {
  display: block;
  width: 100%;
  height: min(320px, 38vh);
  border: 0;
  border-radius: 8px;
  background: #0a0a0a;
}

.bottom-preview-dock {
  position: fixed;
  bottom: 0.75rem;
  left: 0.75rem;
  z-index: 44;
  width: min(380px, 70vw);
  border-radius: 12px;
  overflow: hidden;
  background: #0b57d0;
  border: 2px solid #4f8df0;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), 0 0 0 2px rgba(79, 141, 240, 0.3);
  padding: 0.4rem;
}

.bottom-preview-dock video {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(220px, 26vh);
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #0a0a0a;
  border-radius: 8px;
}

.app {
  width: min(42rem, 100%);
}

.header {
  text-align: center;
  margin-bottom: 2rem;
  position: relative;
}

.header__top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.header__top h1 {
  grid-column: 2;
  margin: 0;
}

.header__top .btn-settings {
  grid-column: 3;
  justify-self: end;
}

.header h1 {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(2.5rem, 8vw, 3.5rem);
  letter-spacing: 0.06em;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.35);
}

.btn-settings {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn-settings:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.35);
}

.btn-settings:active {
  transform: scale(0.96);
}

.btn-settings__icon {
  font-size: 1.35rem;
  line-height: 1;
  display: block;
  margin-top: -0.1em;
}

.hint {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

kbd {
  display: inline-block;
  padding: 0.15em 0.5em;
  font-family: inherit;
  font-size: 0.85em;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  align-items: stretch;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 1.75rem 1rem;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
}

@media (max-width: 520px) {
  .scoreboard {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .divider {
    width: 100%;
    height: 1px;
    min-height: 1px;
  }
}

.team__logo-wrap {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.team__logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.team__logo[hidden] {
  display: none !important;
}

.team__logo-wrap--empty {
  display: none;
}

.team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  border-radius: 14px;
  transition: background 0.2s ease, transform 0.15s ease;
}

.team--flash {
  animation: flash 0.35s ease;
}

@keyframes flash {
  0%,
  100% {
    background: transparent;
  }
  50% {
    background: rgba(255, 255, 255, 0.12);
  }
}

.team__label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.team--1 .team__label {
  color: rgba(255, 200, 180, 0.9);
}

.team--2 .team__label {
  color: rgba(180, 240, 230, 0.95);
}

.team__score {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(4rem, 18vw, 6rem);
  line-height: 1;
  letter-spacing: 0.02em;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.team--1 .team__score {
  color: var(--accent-1);
}

.team--2 .team__score {
  color: var(--accent-2);
}

.divider {
  width: 1px;
  min-width: 1px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(255, 255, 255, 0.2) 15%,
    rgba(255, 255, 255, 0.2) 85%,
    transparent
  );
  align-self: stretch;
}

.btn-add {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  transition: background 0.15s ease, transform 0.1s ease;
}

.team--1 .btn-add:hover {
  background: rgba(255, 107, 53, 0.35);
}

.team--2 .btn-add:hover {
  background: rgba(78, 205, 196, 0.35);
}

.btn-add:active {
  transform: scale(0.97);
}

.team__faults {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.25rem;
  padding: 0.5rem 0.65rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.team__faults-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.team__faults-num {
  font-family: "Bebas Neue", sans-serif;
  font-size: 1.75rem;
  min-width: 1.5ch;
  text-align: center;
  line-height: 1;
}

.team--1 .team__faults-num {
  color: #ffb89a;
}

.team--2 .team__faults-num {
  color: #9ee8e0;
}

.btn-fault {
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.3rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-fault:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.footer {
  margin-top: 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.hik-record-source {
  position: fixed;
  width: 160px;
  height: 90px;
  bottom: 0;
  left: 0;
  opacity: 0.02;
  pointer-events: none;
  z-index: 0;
  object-fit: cover;
}

.hik-ip-record {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.btn-hik-ip {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(78, 205, 196, 0.45);
  background: rgba(78, 205, 196, 0.18);
  color: #e8faf8;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-hik-ip:hover:not(:disabled) {
  background: rgba(78, 205, 196, 0.28);
  border-color: rgba(78, 205, 196, 0.65);
}

.btn-hik-ip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-hik-ip--stop {
  border-color: rgba(255, 107, 53, 0.55);
  background: rgba(255, 107, 53, 0.18);
  color: #ffe8e0;
}

.btn-hik-ip--stop:hover:not(:disabled) {
  background: rgba(255, 107, 53, 0.3);
  border-color: rgba(255, 107, 53, 0.75);
}

.hik-ip-record__hint {
  margin: 0;
  max-width: 28rem;
  font-size: 0.68rem;
  line-height: 1.45;
  color: var(--muted);
}

.hik-ip-record__hint code {
  font-size: 0.62rem;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
}

.btn-reset {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.65rem 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.btn-reset:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.06);
}

.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.modal__panel {
  position: relative;
  z-index: 1;
  width: min(26rem, 100%);
  max-height: min(90dvh, 36rem);
  overflow: auto;
  background: linear-gradient(160deg, #243d32, #1a2e26);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal__title {
  margin: 0;
  font-family: "Bebas Neue", sans-serif;
  font-size: 1.75rem;
  letter-spacing: 0.05em;
  font-weight: 400;
}

.modal__close {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}

.modal__close:hover {
  background: rgba(255, 255, 255, 0.16);
}

.modal__form {
  padding: 1rem 1rem 1.25rem;
}

.config-block {
  margin: 0 0 1.25rem;
  padding: 0 0 1rem;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.config-block:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.config-block legend {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  padding: 0;
}

.config-hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.85em;
}

.field {
  display: block;
  margin-bottom: 0.75rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field__label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.field input[type="text"],
.field input[type="url"] {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

.field input:focus {
  outline: none;
  border-color: rgba(78, 205, 196, 0.55);
  box-shadow: 0 0 0 2px rgba(78, 205, 196, 0.2);
}

.field--file input[type="file"] {
  width: 100%;
  font-size: 0.85rem;
  color: var(--muted);
}

.modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-primary,
.btn-secondary {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 1.15rem;
  border-radius: 999px;
  cursor: pointer;
  border: none;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-primary {
  background: var(--accent-2);
  color: #0f2419;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.btn-secondary:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.45);
}

.config-block--usb {
  padding-bottom: 1rem !important;
}

.config-note {
  margin: 0 0 0.85rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.key-bind {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.65rem;
}

.key-bind:last-child {
  margin-bottom: 0;
}

.key-bind__label {
  flex: 1 1 6rem;
  min-width: 0;
  font-size: 0.85rem;
}

.key-bind__code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--accent-2);
}

.btn-key-assign {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-key-assign:hover {
  background: rgba(255, 255, 255, 0.14);
}

.btn-key-assign.is-waiting {
  border-color: rgba(78, 205, 196, 0.6);
  background: rgba(78, 205, 196, 0.15);
  color: var(--text);
}
