:root {
  --bg-1: #f3f6f4;
  --bg-2: #dfeae4;
  --theme-accent: #1d4ed8;
  --theme-bg-1: #f3f6f4;
  --theme-bg-2: #dfeae4;
  --theme-topbar-1: #eef4ff;
  --theme-topbar-2: #eef2ff;
  --theme-nav: #f0f3f9;
  --panel: #ffffff;
  --ink: #16211f;
  --muted: #52615b;
  --line: #cfdad4;
  --accent: #0c7a5a;
  --accent-2: #09553f;
  --warn: #c74e1d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Trebuchet MS", "Gill Sans", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top right, var(--theme-bg-2), var(--theme-bg-1) 44%);
  scroll-behavior: smooth;
  line-height: 1.35;
}

.splashscreen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.42), transparent 36%),
    radial-gradient(circle at 84% 12%, rgba(233, 38, 54, 0.35), transparent 34%),
    radial-gradient(circle at 55% 88%, rgba(25, 93, 191, 0.36), transparent 36%),
    linear-gradient(135deg, #081c52 0%, #0c2f78 46%, #1e5cc2 100%);
  z-index: 9999;
  transition: opacity 420ms ease, visibility 420ms ease;
}

.splashscreen.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.splash-card {
  position: relative;
  min-width: 280px;
  width: min(86vw, 520px);
  padding: 34px 18px;
  text-align: center;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: linear-gradient(160deg, rgba(9, 33, 95, 0.56), rgba(25, 85, 181, 0.38));
  backdrop-filter: blur(7px);
  box-shadow: 0 20px 48px rgba(7, 24, 71, 0.45);
  overflow: hidden;
}

.splash-title {
  margin: 0;
  color: #ffffff;
  font-size: clamp(1.8rem, 6vw, 2.8rem);
  letter-spacing: 0.03em;
  text-shadow: 0 4px 18px rgba(2, 12, 44, 0.5);
  animation: pop-in 620ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.splash-logo {
  width: clamp(68px, 16vw, 110px);
  height: clamp(68px, 16vw, 110px);
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.32);
  box-shadow: 0 8px 24px rgba(3, 16, 55, 0.45), 0 0 28px rgba(255, 255, 255, 0.35);
  margin-bottom: 10px;
  animation: pop-in 520ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.splash-subtitle {
  margin: 8px 0 0;
  color: #ffffff;
  font-size: clamp(1rem, 2.8vw, 1.25rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  animation: floaty 1700ms ease-in-out infinite;
}

.spark {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.95);
  opacity: 0.8;
}

.spark-a {
  top: 16%;
  left: 18%;
  animation: twinkle 1200ms ease-in-out infinite;
}

.spark-b {
  top: 22%;
  right: 14%;
  animation: twinkle 1300ms ease-in-out infinite 180ms;
}

.spark-c {
  bottom: 22%;
  left: 24%;
  animation: twinkle 1450ms ease-in-out infinite 320ms;
}

.spark-d {
  bottom: 18%;
  right: 20%;
  animation: twinkle 1120ms ease-in-out infinite 100ms;
}

.splash-glow {
  position: absolute;
  left: -12%;
  right: -12%;
  bottom: -40%;
  height: 60%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.65), rgba(227, 43, 60, 0.25), rgba(255, 255, 255, 0));
  filter: blur(6px);
}

@keyframes twinkle {
  0%, 100% { transform: scale(0.75); opacity: 0.35; }
  50% { transform: scale(1.45); opacity: 1; }
}

@keyframes pop-in {
  0% { transform: translateY(8px) scale(0.95); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes sigPulse {
  0%, 100% { text-shadow: 0 0 6px rgba(255, 255, 255, 0.28); }
  50% { text-shadow: 0 0 14px rgba(255, 255, 255, 0.52); }
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% -20%, color-mix(in srgb, var(--theme-accent) 32%, transparent), transparent 58%),
    radial-gradient(circle at 78% 18%, rgba(210, 33, 48, 0.22), transparent 42%),
    linear-gradient(132deg, var(--theme-topbar-1), var(--theme-topbar-2) 55%, #f9f3f4);
}

h1, h2, h3 {
  margin: 0;
  letter-spacing: 0.01em;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.topbar-brand {
  text-align: left;
}

.ucotiga-signature {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(24, 58, 125, 0.34);
  background:
    repeating-linear-gradient(
      -12deg,
      rgba(255, 255, 255, 0.08) 0px,
      rgba(255, 255, 255, 0.08) 2px,
      rgba(255, 255, 255, 0) 2px,
      rgba(255, 255, 255, 0) 6px
    ),
    linear-gradient(108deg, #081f58, #1a56b3 52%, #c31f3b);
  color: #fff;
  box-shadow: 0 10px 24px rgba(7, 27, 74, 0.24);
}

.sig-line {
  width: 24px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.15), #ffffff, rgba(255, 255, 255, 0.15));
}

.sig-text {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.9;
}

.sig-name {
  font-size: 13px;
  letter-spacing: 0.14em;
  font-weight: 900;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
  animation: sigPulse 2200ms ease-in-out infinite;
}

.header-tournament-btn {
  appearance: none;
  border: 1px solid #9eb0bf;
  border-radius: 999px;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.9), rgba(233, 238, 244, 0.78) 45%, rgba(209, 218, 227, 0.8)),
    linear-gradient(130deg, #f8fbff, #e4ebf2);
  color: #112236;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 38, 66, 0.12);
}

.header-tournament-btn .tab-icon {
  display: inline-block;
}

.header-tournament-btn.is-active {
  background:
    radial-gradient(circle at 16% 20%, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0) 35%),
    linear-gradient(120deg, #072a73, #1a58bb 56%, #bc2036);
  color: #fff;
  border-color: #173f8d;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.section-tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 18% 12%, color-mix(in srgb, var(--theme-accent) 22%, transparent), transparent 34%),
    radial-gradient(circle at 88% 18%, rgba(193, 32, 52, 0.14), transparent 30%),
    color-mix(in srgb, var(--theme-nav) 95%, white 5%);
  backdrop-filter: blur(4px);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  white-space: nowrap;
  appearance: none;
  border: 1px solid #b8c6cf;
  border-radius: 12px;
  padding: 10px 16px;
  background: linear-gradient(150deg, #f9fbfd 0%, #e7edf2 100%);
  color: #122231;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(15, 38, 66, 0.1), 0 1px 0 rgba(255, 255, 255, 0.75) inset;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.tab-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(15, 38, 66, 0.15), 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.tab-btn.is-active {
  background: linear-gradient(150deg, #60a5fa 0%, #2563eb 55%, #1e3a8a 100%);
  border-color: #1e3a8a;
  color: #fff;
  box-shadow: 0 7px 16px rgba(13, 43, 99, 0.32);
}

.tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.45em;
  height: 1.25em;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1;
  color: #fff;
  background: linear-gradient(135deg, #08317f, #1d60c6 58%, #c4263f);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22) inset;
}

.tab-icon-ko {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45em;
  height: 1.2em;
  border-radius: 999px;
  background: linear-gradient(135deg, #120f12, #9f1120);
  color: #fff;
  font-size: 0.72em;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.tab-icon-rr {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45em;
  height: 1.2em;
  border-radius: 999px;
  background: linear-gradient(135deg, #171114, #b01729);
  color: #fff;
  font-size: 0.72em;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  padding: 10px 14px;
  cursor: pointer;
}

.btn-accent {
  background: linear-gradient(150deg, #2dd4bf 0%, #0c7a5a 55%, #09553f 100%);
  border-color: var(--accent-2);
  border-radius: 12px;
  color: #fff;
}

.layout {
  padding: 16px;
  display: grid;
  gap: 14px;
  max-width: 1500px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  scroll-margin-top: 72px;
  box-shadow: 0 6px 18px rgba(8, 32, 24, 0.05);
}

.controls {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.small-meta {
  font-size: 12px;
  color: #3f4f59;
  padding: 2px 2px 0;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
}

.inline {
  display: grid;
  gap: 10px;
  grid-template-columns: 2fr 1fr;
  margin-top: 10px;
}

.kpis {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.kpi {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: linear-gradient(180deg, #f9fcfb, #f3f8f5);
}

.kpi .label {
  color: var(--muted);
  font-size: 12px;
}

.kpi .val {
  margin-top: 4px;
  font-weight: 700;
  font-size: 20px;
}

.list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdfc;
}

.player-headline {
  background: linear-gradient(135deg, #eef5ff, #f7fbff);
}

.player-primary-info {
  padding: 12px;
}

.player-primary-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.player-form-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
  color: #0d3a62;
  background: #e2f1ff;
  border: 1px solid #c4dff8;
}

.player-group-line {
  margin-top: 8px;
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #27433b;
}

.player-group-line span {
  border-radius: 999px;
  background: #edf5f2;
  border: 1px solid #d8e7e0;
  padding: 3px 8px;
}

.group-chip {
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, #0e2b71, #0f5ab6) !important;
  border-color: #234f96 !important;
}

.player-kpis {
  margin: 10px 0 12px;
  gap: 6px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.player-kpis .kpi {
  padding: 7px 8px;
  border-radius: 8px;
}

.player-kpis .kpi .label {
  font-size: 11px;
}

.player-kpis .kpi .val {
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.15;
}

.player-search-toolbar {
  position: sticky;
  top: 58px;
  z-index: 5;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.94));
  border: 1px solid #e6ede8;
  border-radius: 10px;
  padding: 8px;
}

.chip-row {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.chip.is-active {
  background: var(--accent);
  border-color: var(--accent-2);
  color: #fff;
}

.player-candidate {
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: grid;
  gap: 2px;
}

.player-candidate .pc-name {
  font-weight: 700;
}

.player-candidate .pc-meta {
  font-size: 12px;
  color: var(--muted);
}

.player-candidate.selected {
  border-color: var(--accent);
  background: #eaf8f2;
  box-shadow: 0 0 0 1px rgba(12, 122, 90, 0.18) inset;
}

.group-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.groups-filter-bar {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) 0.8fr 0.8fr;
  gap: 8px;
  margin: 10px 0 12px;
  padding: 8px;
  border: 1px solid #dde8e2;
  border-radius: 10px;
  background: #f8fbf9;
}

.groups-filter-bar input,
.groups-filter-bar select {
  padding: 7px 9px;
  font-size: 13px;
}

.group-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fcfefe;
}

.live-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(220px, 0.8fr);
  gap: 8px;
  margin: 10px 0 12px;
  padding: 8px;
  border: 1px solid #dde8e2;
  border-radius: 10px;
  background: #f8fbf9;
}

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

.live-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfefe;
  overflow: hidden;
}

.live-card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid #e5efea;
  background: linear-gradient(180deg, #ffffff, #f4faf7);
}

.live-card-title {
  font-weight: 800;
}

.live-card-meta {
  color: var(--muted);
  font-size: 12px;
}

.live-current {
  padding: 10px;
  border-bottom: 1px solid #e7efea;
}

.live-current-empty {
  padding: 14px 10px;
  color: var(--muted);
  font-style: italic;
}

.live-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.live-row .left { text-align: left; }
.live-row .right { text-align: right; }

.live-score {
  font-weight: 900;
  font-size: 18px;
}

.live-sub {
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.live-queue {
  padding: 6px 10px 10px;
}

.live-queue-title {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
}

.live-queue-item {
  padding: 7px 8px;
  border: 1px solid #e7efea;
  border-radius: 8px;
  background: #f9fcfa;
  margin-bottom: 6px;
}

.status-chip {
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
}

.status-waiting {
  background: #f4f1df;
  color: #7b5b00;
}

.status-playing {
  background: #dff3fb;
  color: #045d86;
}

.status-finished {
  background: #e1f3ea;
  color: #0d6a41;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 13px;
  min-width: 580px;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 8px 7px;
  text-align: left;
}

thead th {
  position: sticky;
  top: 0;
  background: #eef5f1;
  z-index: 1;
}

tbody tr:nth-child(even) {
  background: #f9fcfa;
}

.muted {
  color: var(--muted);
}

.notice {
  color: var(--warn);
  font-weight: 600;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #e7efea;
  border-radius: 8px;
}

.hidden {
  display: none !important;
}

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

@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 14px;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .btn {
    flex: 1;
    text-align: center;
  }

  .layout {
    padding: 10px;
    gap: 10px;
  }

  .ucotiga-signature {
    gap: 7px;
    padding: 5px 9px;
  }

  .sig-line {
    width: 16px;
  }

  .sig-name {
    font-size: 11px;
  }

  .section-tabs {
    padding: 8px 10px;
  }

  .tab-icon {
    display: inline-flex;
    font-size: 10.5px;
  }

  .tab-label {
    display: none;
  }

  .tab-btn {
    min-width: 48px;
    justify-content: center;
    padding: 7px 12px;
    gap: 0;
  }

  .panel {
    padding: 10px;
  }

  .header-tournament-btn {
    align-self: stretch;
    justify-content: center;
  }

  .player-search-toolbar {
    top: 50px;
    padding: 7px;
  }

  .chip-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .chip {
    padding: 8px 6px;
    text-align: center;
  }

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

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

  .groups-filter-bar {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    padding: 7px;
  }

  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .player-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .live-toolbar {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .splash-title,
  .splash-subtitle,
  .spark {
    animation: none;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 1.35rem;
  }

  h2 {
    font-size: 1.05rem;
  }

  .btn {
    padding: 9px 10px;
    font-size: 0.92rem;
  }

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

  .kpi .val {
    font-size: 18px;
  }

  .player-kpis {
    grid-template-columns: 1fr 1fr;
    gap: 5px;
  }

  .player-kpis .kpi {
    padding: 6px 7px;
  }

  .player-kpis .kpi .label {
    font-size: 10.5px;
  }

  .player-kpis .kpi .val {
    font-size: 12px;
  }

  .player-search-toolbar {
    top: 46px;
  }

  .player-candidate {
    padding: 12px;
  }

  .player-primary-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .player-form-chip {
    width: fit-content;
  }

  .groups-filter-bar {
    grid-template-columns: 1fr;
  }

  table {
    font-size: 12px;
    min-width: 520px;
  }
}
