* {
  box-sizing: border-box;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

body {
  margin: 0;
  font-family: "Inter", -apple-system, system-ui, sans-serif;
  background: 
    conic-gradient(from 180deg at 12% 8%, rgba(20, 83, 158, 0.08), transparent 45deg),
    conic-gradient(from 45deg at 88% 15%, rgba(5, 150, 105, 0.06), transparent 50deg),
    repeating-linear-gradient(
      115deg,
      rgba(30, 41, 59, 0.03) 0px,
      transparent 1px,
      transparent 24px,
      rgba(30, 41, 59, 0.03) 25px
    ),
    #0a0e1a;
  color: #f1f5f9;
  min-height: 100vh;
  font-weight: 400;
  line-height: 1.6;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.header-content {
  flex: 1;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 30%, #94a3b8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  position: relative;
}

h1::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 42px;
  height: 3px;
  background: linear-gradient(90deg, #0ea5e9, #06b6d4);
  border-radius: 2px;
}

.subtitle {
  margin: 12px 0 0;
  color: #94a3b8;
  font-size: 0.95rem;
  font-weight: 300;
}

.edit-btn {
  background: 
    linear-gradient(135deg, rgba(71, 85, 105, 0.8) 0%, rgba(51, 65, 85, 0.9) 100%);
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 4px;
}

.edit-btn:hover {
  background: 
    linear-gradient(135deg, rgba(59, 130, 246, 0.7) 0%, rgba(79, 70, 229, 0.8) 100%);
  border-color: rgba(59, 130, 246, 0.5);
  transform: translateY(-1px);
}

.controls {
  background: 
    linear-gradient(135deg, rgba(15, 23, 42, 0.85) 0%, rgba(30, 41, 59, 0.75) 100%),
    linear-gradient(45deg, transparent 48%, rgba(59, 130, 246, 0.03) 50%, transparent 52%);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-left-color: rgba(59, 130, 246, 0.3);
  border-radius: 18px;
  padding: 20px;
  display: grid;
  gap: 14px;
  backdrop-filter: blur(8px);
  box-shadow: 
    0 20px 50px rgba(2, 6, 23, 0.6),
    inset 0 1px 0 rgba(148, 163, 184, 0.1);
}

label {
  font-weight: 500;
  color: #e2e8f0;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

select,
textarea,
button {
  font-family: inherit;
}

select,
textarea {
  width: 100%;
  border: 1px solid rgba(71, 85, 105, 0.4);
  border-radius: 12px;
  padding: 12px 14px;
  background: 
    linear-gradient(145deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.9) 100%);
  color: #f1f5f9;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

button {
  width: fit-content;
  border: none;
  border-radius: 14px;
  padding: 12px 20px;
  background: 
    linear-gradient(135deg, #0ea5e9 0%, #3b82f6 50%, #6366f1 100%);
  color: #ffffff;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  box-shadow: 
    0 12px 28px rgba(59, 130, 246, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 
    0 16px 35px rgba(59, 130, 246, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.note {
  margin: 2px 0 0;
  color: #93c5fd;
  font-size: 0.92rem;
}

.message {
  min-height: 20px;
  margin: 12px 0 16px;
  color: #fca5a5;
  font-weight: 600;
}

.bracket-root {
  display: grid;
  gap: 20px;
}

.bracket-section {
  background: 
    linear-gradient(145deg, rgba(15, 23, 42, 0.85) 0%, rgba(30, 41, 59, 0.8) 100%);
  border: 1px solid rgba(71, 85, 105, 0.25);
  border-top-color: rgba(148, 163, 184, 0.3);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 
    0 20px 45px rgba(2, 6, 23, 0.6),
    inset 0 1px 0 rgba(148, 163, 184, 0.08);
  position: relative;
}

.bracket-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20px;
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, #0ea5e9, #06b6d4);
  border-radius: 1px;
}

.bracket-section h2 {
  margin: 0 0 16px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -0.01em;
}

.rounds {
  overflow: auto;
  max-height: 64vh;
  padding-bottom: 8px;
  border-radius: 10px;
}

.rounds-track {
  position: relative;
  display: flex;
  gap: 24px;
  width: max-content;
  min-width: 100%;
  padding: 4px 8px 8px;
}

.connector-layer {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 0;
}

.round,
.match {
  position: relative;
  z-index: 1;
}

.round {
  min-width: 220px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
}

.round h3 {
  margin: 0 0 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: "JetBrains Mono", monospace;
}

.match {
  border: 1px solid rgba(71, 85, 105, 0.4);
  border-left-color: rgba(59, 130, 246, 0.2);
  border-radius: 16px;
  background: 
    linear-gradient(135deg, rgba(15, 23, 42, 0.9) 0%, rgba(30, 41, 59, 0.85) 100%);
  padding: 10px;
  margin-bottom: 18px;
  box-shadow: 
    0 8px 25px rgba(2, 6, 23, 0.4),
    inset 0 1px 0 rgba(148, 163, 184, 0.06);
  position: relative;
}

.match::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.6), rgba(16, 185, 129, 0.4));
  border-radius: 16px 0 0 16px;
}

.player-btn {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(71, 85, 105, 0.3);
  background: 
    linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(51, 65, 85, 0.9) 100%);
  color: #e2e8f0;
  margin-bottom: 8px;
  padding: 11px 12px;
  font-weight: 500;
  font-size: 0.9rem;
  border-radius: 10px;
  transition: all 0.15s ease;
  cursor: pointer;
}

.player-btn:last-of-type {
  margin-bottom: 0;
}

.player-btn:not(:disabled):hover {
  border-color: rgba(59, 130, 246, 0.5);
  background: 
    linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(30, 41, 59, 0.95) 100%);
  transform: translateX(2px);
}

.player-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  background: rgba(51, 65, 85, 0.6);
  color: #64748b;
  transform: none;
}

.player-btn.selected {
  background: 
    linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
  color: #ffffff;
  border-color: rgba(16, 185, 129, 0.7);
  box-shadow: 
    0 0 20px rgba(16, 185, 129, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateX(3px);
}

.final-match {
  border-color: rgba(251, 191, 36, 0.4);
  background: 
    linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.9) 100%),
    linear-gradient(45deg, transparent 48%, rgba(251, 191, 36, 0.03) 50%, transparent 52%);
}

.final-match::before {
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.8), rgba(245, 158, 11, 0.6));
}

.final-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #fbbf24;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  font-family: "JetBrains Mono", monospace;
}

.champion {
  margin-top: 18px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fbbf24;
  background: 
    linear-gradient(135deg, rgba(251, 191, 36, 0.1) 0%, rgba(245, 158, 11, 0.05) 100%);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 12px;
  text-align: center;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
}
