:root {
  color-scheme: dark;
  --bg: #0b0812;
  --surface: rgba(25, 19, 40, 0.9);
  --surface-strong: #211831;
  --line: rgba(195, 156, 255, 0.16);
  --text: #f5f1ff;
  --muted: #aaa1ba;
  --purple: #9b5cff;
  --purple-bright: #bd8aff;
  --pink: #e65cff;
  --cyan: #57d8ff;
  --danger: #ff718f;
  --success: #70efb4;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 300px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top, rgba(91, 42, 148, 0.16), transparent 34rem),
    var(--bg);
  color: var(--text);
}

button, input { font: inherit; }
button { touch-action: manipulation; }

.background-glow {
  position: fixed;
  z-index: -1;
  width: 24rem;
  height: 24rem;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.13;
  pointer-events: none;
}

.background-glow--one { top: 15%; left: -10rem; background: var(--purple); }
.background-glow--two { right: -12rem; bottom: 5%; background: var(--cyan); }

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 64px;
}

.hero,
.section-heading,
.drop-zone__heading,
.draw-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.hero { margin-bottom: 28px; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 9px; font-size: clamp(2rem, 5vw, 3.45rem); line-height: 1; letter-spacing: -0.045em; }
h2 { margin-bottom: 0; font-size: clamp(1.25rem, 3vw, 1.65rem); }
h3 { margin: 0; font-size: 1rem; }

.eyebrow, .section-kicker {
  margin-bottom: 7px;
  color: var(--purple-bright);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.subtitle { max-width: 600px; margin-bottom: 0; color: var(--muted); line-height: 1.55; }

.panel, .results {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
}

.mode-control {
  min-width: 220px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mode-control > span { display: block; margin-bottom: 8px; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0,0,0,.22); }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span { display: block; padding: 9px 12px; border-radius: 8px; color: var(--muted); text-align: center; cursor: pointer; transition: .18s ease; }
.segmented-control input:checked + span { color: white; background: linear-gradient(135deg, #7240da, #9a4bea); box-shadow: 0 4px 14px rgba(143, 74, 238, .35); }
.segmented-control input:focus-visible + span { outline: 2px solid var(--cyan); outline-offset: 2px; }

.add-player-form { display: flex; gap: 9px; }
input[type="text"] { width: min(250px, 45vw); padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; outline: none; color: var(--text); background: rgba(5, 3, 10, .42); }
input[type="text"]:focus { border-color: var(--purple-bright); box-shadow: 0 0 0 3px rgba(155, 92, 255, .15); }

.button { min-height: 43px; padding: 10px 17px; border: 1px solid transparent; border-radius: 11px; color: white; font-weight: 750; cursor: pointer; transition: transform .16s ease, filter .16s ease, border-color .16s ease; }
.button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.button:active { transform: translateY(0); }
.button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.button--primary { min-width: 180px; background: linear-gradient(135deg, #7740e4, #b34ee9); box-shadow: 0 8px 28px rgba(137, 68, 232, .28); }
.button--secondary { background: var(--surface-strong); border-color: var(--line); }
.button--ghost { color: var(--muted); background: transparent; border-color: var(--line); }

.message { min-height: 1.25em; margin: 12px 0 0; color: var(--danger); font-size: .9rem; }
.message--success { color: var(--success); }

.player-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 8px; }
.drop-zone { min-height: 245px; padding: 17px; border: 1px dashed rgba(187, 139, 255, .25); border-radius: 14px; background: rgba(4, 3, 10, .25); transition: border-color .16s ease, background .16s ease, box-shadow .16s ease; }
.drop-zone--participants { background: rgba(115, 59, 190, .07); }
.drop-zone.is-dragover { border-color: var(--purple-bright); background: rgba(155, 92, 255, .16); box-shadow: inset 0 0 0 1px rgba(195, 156, 255, .18), 0 0 24px rgba(155, 92, 255, .12); }
.count { display: grid; min-width: 28px; height: 28px; place-items: center; border-radius: 99px; color: var(--purple-bright); background: rgba(155, 92, 255, .12); font-size: .8rem; font-weight: 800; }
.player-list { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }
.player-card { display: inline-flex; align-items: center; gap: 8px; min-height: 41px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--surface-strong); box-shadow: 0 5px 14px rgba(0,0,0,.15); cursor: grab; user-select: none; transition: transform .15s ease, border-color .15s ease; }
.player-card:hover { border-color: rgba(190, 137, 255, .48); transform: translateY(-1px); }
.player-card:active { cursor: grabbing; }
.player-card__move { color: var(--muted); font-size: .78rem; }
.player-card__delete { display: grid; width: 25px; height: 25px; margin: -2px -4px -2px 0; padding: 0; place-items: center; border: 0; border-radius: 7px; color: var(--muted); background: rgba(255,255,255,.04); cursor: pointer; }
.player-card__delete:hover { color: white; background: rgba(255, 113, 143, .22); }
.empty-state { display: none; margin: 54px 8px 0; color: #746d80; text-align: center; font-size: .9rem; }
.drop-zone:has(.player-list:empty) .empty-state { display: block; }

.draw-actions { justify-content: center; flex-wrap: wrap; padding: 22px 0; }
.draw-message { flex-basis: 100%; margin: -8px 0 0; text-align: center; }

.results { overflow: hidden; background: linear-gradient(145deg, rgba(47, 28, 71, .92), rgba(18, 14, 29, .94)); }
.round-badge { padding: 7px 11px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: .8rem; }
.team-grid { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: 18px; margin-top: 20px; }
.team-card { min-height: 155px; padding: 21px; border: 1px solid var(--line); border-radius: 15px; }
.team-card--one { background: linear-gradient(145deg, rgba(155,92,255,.18), rgba(155,92,255,.04)); }
.team-card--two { background: linear-gradient(145deg, rgba(87,216,255,.14), rgba(87,216,255,.03)); }
.team-label { margin-bottom: 13px; color: var(--purple-bright); font-size: .77rem; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.team-card--two .team-label { color: var(--cyan); }
.team-members { margin: 0; padding: 0; list-style: none; font-size: clamp(1.08rem, 2.4vw, 1.35rem); font-weight: 700; line-height: 1.6; }
.team-placeholder { color: #71687e; }
.versus { align-self: center; color: var(--muted); font-size: .78rem; font-weight: 900; letter-spacing: .12em; }
.team-grid.is-new .team-card { animation: reveal-team .42s cubic-bezier(.2,.85,.3,1); }
.team-grid.is-new .team-card--two { animation-delay: .07s; }
@keyframes reveal-team { from { opacity: .2; transform: translateY(9px) scale(.985); } to { opacity: 1; transform: none; } }

.history-panel { margin-top: 22px; }
.history-list { display: grid; gap: 10px; margin-top: 17px; }
.history-entry { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 14px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 11px; background: rgba(0,0,0,.15); }
.history-entry p { margin: 0; color: var(--muted); line-height: 1.45; }
.history-entry strong { color: var(--text); }
.history-round { color: var(--purple-bright) !important; font-weight: 800; }
.history-empty { margin: 0; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 720px) {
  .app-shell { width: min(100% - 22px, 1120px); padding-top: 24px; }
  .hero, .section-heading { align-items: stretch; flex-direction: column; }
  .mode-control { width: 100%; }
  .add-player-form { width: 100%; }
  input[type="text"] { flex: 1; width: auto; min-width: 0; }
  .player-columns { grid-template-columns: 1fr; }
  .drop-zone { min-height: 180px; }
  .team-grid { grid-template-columns: 1fr; gap: 10px; }
  .versus { justify-self: center; }
  .history-entry { grid-template-columns: 1fr; gap: 5px; }
}

@media (max-width: 430px) {
  .panel, .results { padding: 17px; }
  .add-player-form { flex-direction: column; }
  .add-player-form .button, .draw-actions .button { width: 100%; }
  .player-card { max-width: 100%; }
  .player-card__name { overflow: hidden; text-overflow: ellipsis; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
