:root {
  --bg: #07080d;
  --panel: rgba(10, 14, 24, 0.88);
  --line: rgba(232, 196, 90, 0.22);
  --text: #f4efe3;
  --muted: #9aa3b5;
  --gold: #e8c45a;
  --gold-deep: #b88a1f;
  --blue: #3aa0ff;
  --red: #ff4b4b;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Rajdhani", "Segoe UI", sans-serif;
}

body {
  position: relative;
  padding: 20px 14px 40px;
  overflow-x: hidden;
}

.fx {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(58, 160, 255, 0.16), transparent 32%),
    radial-gradient(circle at 88% 10%, rgba(255, 75, 75, 0.14), transparent 30%),
    radial-gradient(circle at 50% 120%, rgba(232, 196, 90, 0.1), transparent 38%),
    linear-gradient(180deg, #0b101a 0%, #07080d 55%, #05060a 100%);
}

.fx::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.16;
  background-image:
    linear-gradient(rgba(232, 196, 90, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232, 196, 90, 0.12) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, black 30%, transparent 78%);
}

.app {
  position: relative;
  z-index: 1;
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.topbar,
.pool,
.side,
.bench-wrap,
.history {
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.header-actions,
.toolbar,
.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-actions {
  justify-content: flex-end;
}

.toolbar {
  flex-wrap: wrap;
}

.toolbar .status {
  margin: 0;
}

.icon-btn {
  position: relative;
  width: 48px;
  height: 48px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold);
  background: #0c1018;
  color: var(--gold);
}

.icon-btn svg {
  width: 24px;
  height: 24px;
}

.icon-count {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 22px;
  padding: 2px 5px;
  border: 1px solid var(--gold);
  background: #1a1406;
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 700;
}

.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 10, 0.78);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: min(88vh, 860px);
  overflow: auto;
  padding: 18px;
  background: #0c1018;
  border: 1px solid var(--line);
}

.modal-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-head h2 {
  margin: 0;
}

body.modal-open {
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 22px 100%, 0 calc(100% - 22px));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 14px;
  height: 42px;
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
}

.brand-kicker,
.kicker,
.side-head p,
.match-chips span,
.role,
.slot,
.count,
.status,
.error {
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand-kicker,
.kicker,
.side-head p {
  margin: 0;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 700;
}

h1,
h2,
.primary,
.vs-label {
  font-family: "Orbitron", "Rajdhani", sans-serif;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(1.05rem, 3.4vw, 1.7rem);
  letter-spacing: 0.05em;
  line-height: 1.15;
}

.match-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.match-chips span,
.count {
  border: 1px solid var(--line);
  color: var(--gold);
  padding: 6px 10px;
  font-size: 0.72rem;
  font-weight: 700;
}

.arena {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: stretch;
}

.side {
  padding: 0;
  overflow: hidden;
}

.side.blue {
  border-color: rgba(58, 160, 255, 0.4);
}

.side.red {
  border-color: rgba(255, 75, 75, 0.4);
}

.side-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 14px 16px;
}

.side.blue .side-head {
  background: linear-gradient(90deg, rgba(58, 160, 255, 0.28), rgba(58, 160, 255, 0.04));
  border-bottom: 1px solid rgba(58, 160, 255, 0.35);
}

.side.red .side-head {
  background: linear-gradient(270deg, rgba(255, 75, 75, 0.28), rgba(255, 75, 75, 0.04));
  border-bottom: 1px solid rgba(255, 75, 75, 0.35);
}

.side.blue h2,
.side.red h2 {
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  letter-spacing: 0.08em;
}

.side.blue h2 { color: var(--blue); }
.side.red h2 { color: var(--red); }

.vs {
  display: grid;
  place-items: center;
  align-self: center;
  position: relative;
  width: 110px;
}

.vs span {
  width: 86px;
  height: 86px;
  border: 1px solid var(--gold);
  background: #0c0e14;
  transform: rotate(45deg);
  box-shadow: 0 0 0 8px #07080d, 0 0 28px rgba(232, 196, 90, 0.28);
}

.vs-label {
  position: absolute;
  color: var(--gold);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.side ol,
.player-list,
.bench-wrap ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.side ol {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.player-card,
.empty-slot {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.blue .player-card {
  background: linear-gradient(90deg, rgba(58, 160, 255, 0.12), rgba(255, 255, 255, 0.02));
  border-left: 3px solid var(--blue);
}

.red .player-card {
  background: linear-gradient(90deg, rgba(255, 75, 75, 0.12), rgba(255, 255, 255, 0.02));
  border-left: 3px solid var(--red);
}

.avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--gold);
  background: #0c1018;
  color: var(--gold);
  font-family: "Orbitron", sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
}

.blue .player-card .avatar {
  border-color: var(--blue);
  color: var(--blue);
}

.red .player-card .avatar {
  border-color: var(--red);
  color: var(--red);
}

.slot {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.player-card strong,
.empty-slot strong {
  display: block;
  font-size: 1.15rem;
  line-height: 1.1;
}

.empty-slot {
  opacity: 0.5;
}

.shuffle {
  animation: reveal 320ms ease both;
}

.red .shuffle {
  animation-name: reveal-right;
}

.pool,
.bench-wrap,
.history {
  padding: 18px;
}

.pool-head,
.bench-head,
.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.pool h2,
.bench-wrap h2 {
  font-size: 1rem;
}

.lede {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.editor {
  border-color: rgba(232, 196, 90, 0.5);
}

.add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 10px;
}

input,
button {
  font: inherit;
}

input {
  flex: 1;
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--line);
  background: #0a0d14;
  color: var(--text);
}

input:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

button {
  border: 0;
  padding: 13px 16px;
  background: #161b27;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

button:hover:not(:disabled) {
  background: #1f2636;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.primary {
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
  color: #1a1406;
  min-width: 190px;
}

button.primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

button.remove {
  padding: 0 8px;
  background: transparent;
  color: var(--muted);
  letter-spacing: 0;
}

button.remove:hover {
  color: var(--danger);
}

.player-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
  min-height: 44px;
}

.profile-card {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #0a0d14;
}

.profile-actions {
  display: flex;
  gap: 6px;
}

.profile-actions .edit,
.profile-actions .remove {
  padding: 8px 10px;
}

.profile-card .avatar {
  width: 42px;
  height: 42px;
  font-size: 0.95rem;
}

.profile-card small {
  display: block;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.68rem;
}

.actions {
  margin-top: 16px;
  justify-content: flex-start;
}

.status,
.error {
  margin: 12px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.error {
  color: var(--danger);
}

.bench-wrap {
  border-color: rgba(232, 196, 90, 0.28);
}

.bench-wrap ol {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.bench-wrap li {
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: #0a0d14;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@keyframes reveal {
  from { transform: translateX(-8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes reveal-right {
  from { transform: translateX(8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.history-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.history-card {
  padding: 14px;
  border: 1px solid var(--line);
  background: #0a0d14;
}

.history-card.live {
  border-color: rgba(232, 196, 90, 0.45);
}

.history-card h3 {
  margin: 0;
  font-family: "Orbitron", "Rajdhani", sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.history-card header p,
.history-bench {
  margin: 6px 0 0;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.history-teams {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.history-teams p,
.install-steps,
.install-form {
  margin: 0;
}

.history-teams strong {
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.install-steps {
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.install-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.install-form label {
  display: grid;
  gap: 6px;
  color: var(--gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.install-form select {
  font: inherit;
  padding: 13px 14px;
  border: 1px solid var(--line);
  background: #0a0d14;
  color: var(--text);
}

.primary-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 860px) {
  .arena,
  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .vs {
    width: 100%;
    padding: 6px 0;
  }

  .side.red {
    box-shadow: inset 4px 0 0 var(--red);
  }

  button.primary,
  .add-form button {
    width: 100%;
  }

  .history-teams {
    grid-template-columns: 1fr;
  }
}
