:root {
  --bg: #0b1020;
  --bg-radial-1: rgba(122, 60, 255, 0.14);
  --bg-radial-2: rgba(61, 217, 235, 0.14);
  --panel: rgba(255, 255, 255, 0.07);
  --panel-2: rgba(255, 255, 255, 0.05);
  --glass: rgba(255, 255, 255, 0.1);
  --text: #e6ebf7;
  --muted: #b0b9d4;
  --accent: linear-gradient(135deg, #7a3cff, #3dd9eb);
  --accent-solid: #7a3cff;
  --accent-2: #ff8bd1;
  --accent-text: #05060f;
  --border: rgba(255, 255, 255, 0.14);
  --chip: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(255, 255, 255, 0.05);
  --input-border: rgba(255, 255, 255, 0.22);
  --input-focus-ring: rgba(122, 60, 255, 0.22);
  --input-shadow: 0 8px 20px rgba(2, 8, 23, 0.2);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --good: #5ce8a0;
  --bad: #ff8dae;
}

[data-theme="light"] {
  --bg: #e9eef8;
  --bg-radial-1: rgba(122, 60, 255, 0.12);
  --bg-radial-2: rgba(61, 217, 235, 0.11);
  --panel: rgba(246, 250, 255, 0.78);
  --panel-2: rgba(245, 249, 255, 0.66);
  --glass: rgba(245, 249, 255, 0.68);
  --text: #12182a;
  --muted: #4c5a80;
  --accent: linear-gradient(135deg, #7a3cff, #3dd9eb);
  --accent-solid: #7a3cff;
  --accent-2: #ff8bd1;
  --accent-text: #f7f9ff;
  --border: rgba(26, 37, 72, 0.16);
  --chip: rgba(122, 60, 255, 0.08);
  --input-bg: rgba(255, 255, 255, 0.84);
  --input-border: rgba(36, 77, 227, 0.18);
  --input-focus-ring: rgba(122, 60, 255, 0.18);
  --input-shadow: 0 10px 24px rgba(16, 28, 74, 0.14);
  --shadow: 0 22px 55px rgba(16, 28, 74, 0.18);
  --good: #059669;
  --bad: #dc2626;
}

* {
  box-sizing: border-box;
}

*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Avenir Next", "Nunito Sans", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 20%, var(--bg-radial-1), transparent 35%),
    radial-gradient(circle at 80% 10%, var(--bg-radial-2), transparent 30%),
    var(--bg);
  min-height: 100vh;
  position: relative;
}

/* Theme Toggle Button */
.theme-toggle {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 50px;
  width: 48px;
  height: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.theme-toggle:hover {
  border-color: var(--accent-solid);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.theme-toggle:active {
  transform: scale(0.98);
}

.theme-icon {
  font-size: 12px;
  transition: all 0.3s ease;
  display: inline-block;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
}

.theme-icon.active {
  opacity: 1;
}

/* Toggle switch effect */
.theme-toggle::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: var(--accent-solid);
  border-radius: 50%;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .theme-toggle::before {
  transform: translateX(22px);
}

[data-theme="light"] .theme-toggle::before {
  transform: translateX(0);
}

/* App Header with Logo */
.app-header {
  background: var(--glass);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 24px;
}

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

.logo {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

.app-name {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.shell-header {
  max-width: 1220px;
  margin: 0 auto;
  padding: 20px 24px 12px;
}

.shell-header p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.shell-main {
  max-width: 1220px;
  margin: 0 auto;
  padding: 14px 24px 44px;
}

.step-nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  margin-bottom: 18px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.step-pill {
  border: 1px solid var(--border);
  color: var(--text);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-radius: 12px;
  padding: 13px 24px 13px 20px;
  font-size: 16px;
  cursor: pointer;
  font-weight: 700;
  position: relative;
  overflow: hidden;
  min-width: 210px;
  text-align: center;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 0 100%, 14px 50%);
  margin-right: -10px;
  z-index: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 4px 14px rgba(8, 14, 28, 0.35);
}

.step-pill.active {
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid rgba(206, 245, 255, 0.9);
  box-shadow: 0 10px 26px rgba(122, 60, 255, 0.35);
  z-index: 3;
}

.step-pill.active::after {
  content: "";
  position: absolute;
  top: -35%;
  left: -28%;
  width: 38%;
  height: 170%;
  transform: rotate(18deg);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0));
  animation: stepShine 2.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes stepShine {
  0% {
    left: -35%;
  }

  55% {
    left: 112%;
  }

  100% {
    left: 112%;
  }
}

.step-pill:first-child {
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 0 100%);
}

.step-pill:last-child {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 14px 50%);
  margin-right: 0;
}

.step-pill:only-child {
  clip-path: none;
  border-radius: 12px;
}

.panel {
  display: none;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}

.panel.active {
  display: block;
}

h2 {
  margin-top: 0;
  font-size: 30px;
  font-family: "Space Grotesk", "Manrope", sans-serif;
  letter-spacing: 0.01em;
}

h3 {
  margin: 0;
  font-size: 19px;
  font-family: "Space Grotesk", "Manrope", sans-serif;
  letter-spacing: 0.01em;
}

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

.full {
  grid-column: 1 / -1;
}

/* Match Form Redesign */
.match-form-grid {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.form-row {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 2rem;
  align-items: start;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-weight: 500;
  color: var(--text);
  font-size: 14px;
  margin: 0;
}

.form-group input {
  padding: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  background: var(--input-bg);
  border-color: var(--input-border);
  color: var(--text);
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  box-shadow: var(--input-shadow);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-solid);
  box-shadow: 0 0 0 4px var(--input-focus-ring), var(--input-shadow);
  background: var(--panel);
}

.form-group input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.match-vs-inline {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem;
  background: linear-gradient(170deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.team-input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.team-input-group label {
  font-weight: 500;
  color: var(--text);
  font-size: 14px;
  margin: 0;
}

.team-input-group input {
  padding: 1rem;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  background: var(--input-bg);
  color: var(--text);
  transition: all 0.3s ease;
  backdrop-filter: blur(8px);
  box-shadow: var(--input-shadow);
}

.team-input-group input:focus {
  outline: none;
  border-color: var(--accent-solid);
  box-shadow: 0 0 0 4px var(--input-focus-ring), var(--input-shadow);
  background: var(--panel);
}

.team-input-group input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.vs-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 8px 24px rgba(122, 60, 255, 0.3), 0 0 0 3px var(--panel);
  backdrop-filter: blur(8px);
}

@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .match-vs-inline {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }

  .vs-divider {
    width: 45px;
    height: 45px;
    font-size: 12px;
    order: -1;
  }

  .team-input-group {
    width: 100%;
  }
}

label {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 16px;
}

input,
select,
textarea {
  max-width: 100%;
  width: 100%;
  padding: 0.875rem;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  font-size: 15px;
  background: var(--input-bg);
  color: var(--text);
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  box-shadow: var(--input-shadow);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-solid);
  box-shadow: 0 0 0 4px var(--input-focus-ring), var(--input-shadow);
  background: var(--panel);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

button {
  max-width: 100%;
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

button[type="submit"] {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 8px 24px rgba(122, 60, 255, 0.3), 0 0 0 3px rgba(255, 255, 255, 0.1);
}

button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(122, 60, 255, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.15);
}

button.ghost {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
}

button.ghost:hover {
  background: var(--chip);
  border-color: var(--accent-solid);
  transform: translateY(-1px);
}

.inline-form {
  display: flex;
  align-items: start;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-form input,
.inline-form select {
  min-width: 0;
  flex: 1 1 220px;
}

.grid > *,
.form-row > *,
.match-vs-inline > *,
.rank-select-row > *,
.inline-form > * {
  min-width: 0;
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
}

.line-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.stack {
  display: grid;
  gap: 10px;
}

.payout-row {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 10px;
  align-items: center;
  background: linear-gradient(170deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}

.payout-row .remove {
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 10px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle input {
  width: auto;
  margin: 0;
}

.hidden {
  display: none !important;
}

.soft-box {
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 14px;
}

.chips {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.chips li {
  background: var(--chip);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chips .remove {
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  padding: 4px 7px;
}

.feed {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.feed-item {
  border: 1px solid var(--border);
  background: linear-gradient(170deg, var(--panel), var(--panel-2));
  border-radius: 14px;
  padding: 14px;
  color: var(--muted);
}

.rank-card {
  background: linear-gradient(170deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.rank-card h4 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 21px;
}

.rank-select-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 10px;
}

.rank-select-row .remove {
  background: var(--panel-2);
  color: var(--text);
}

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

.small {
  font-size: 15px;
}

.flow-controls {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  font-size: 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 13px;
}

.pos {
  color: var(--good);
}

.neg {
  color: var(--bad);
}

@media (max-width: 760px) {
  .header-content {
    padding: 0 14px;
  }

  .shell-header {
    padding: 16px 14px 8px;
  }

  .shell-main {
    padding: 10px 14px 28px;
  }

  .panel {
    padding: 16px;
    border-radius: 14px;
  }

  h2 {
    font-size: 24px;
  }

  h3 {
    font-size: 17px;
  }

  .line-head {
    flex-wrap: wrap;
  }

  .line-head > * {
    min-width: 0;
  }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-form input,
  .inline-form select,
  .inline-form button {
    width: 100%;
  }

  .match-vs-inline {
    width: 100%;
  }

  .team-input-group,
  .form-group,
  .autocomplete {
    width: 100%;
  }

  .payout-row,
  .rank-select-row {
    grid-template-columns: 1fr;
  }

  .flow-controls {
    flex-direction: column;
  }

  .step-nav {
    display: grid;
    grid-template-columns: 1fr;
  }

  .step-pill,
  .step-pill:first-child,
  .step-pill:last-child {
    clip-path: none;
    border-radius: 12px;
    min-width: 0;
    padding: 12px 14px;
    margin-right: 0;
  }

  .flow-controls button {
    width: 100%;
  }

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

  .theme-toggle {
    top: 0.75rem;
    right: 0.75rem;
  }

  #step-ledger {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 520px;
  }

  th,
  td {
    font-size: 14px;
    padding: 10px 8px;
  }
}

.autocomplete {
  position: relative;
  min-width: 0;
}

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 300;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(170deg, var(--panel), var(--panel-2));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  max-height: 220px;
  overflow-y: auto;
  padding: 6px;
  display: grid;
  gap: 4px;
}

.suggestion-item {
  width: 100%;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px;
  font-size: 15px;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: var(--chip);
  border-color: var(--border);
}


.suggestions.hidden {
  display: none !important;
}

.field-error {
  border-color: var(--bad);
  box-shadow: 0 0 0 1px rgba(255, 141, 174, 0.35);
}

.winner-feedback {
  margin: 0 0 10px;
  border: 1px solid rgba(255, 141, 174, 0.4);
  border-radius: 12px;
  color: #ffd5e2;
  background: rgba(255, 80, 130, 0.12);
  padding: 12px 14px;
  font-size: 15px;
}

.payout-row {
  grid-template-columns: minmax(170px, 220px) 1fr auto;
}

.payout-rank-display {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--chip);
  padding: 12px 14px;
  font-size: 15px;
}

.rank-icon {
  font-size: 22px;
  line-height: 1;
}

.rank-text {
  font-size: 16px;
  letter-spacing: 0.01em;
}

.payout-total {
  margin: 10px 2px 0;
  font-weight: 700;
  font-size: 15px;
}

.payout-match {
  color: var(--good);
}

.payout-mismatch {
  color: var(--bad);
}

/* Positioning fixes: step flow + winners layout */
.step-nav {
  gap: 2px;
}

.step-pill {
  margin-right: 0;
}

.step-pill+.step-pill {
  margin-left: -6px;
}

#step-winners .inline-form {
  align-items: stretch;
}

#step-winners #load-winner-form {
  min-width: 210px;
}

.winners-stack,
#winners-form {
  margin-top: 14px;
  gap: 14px;
}

.rank-card {
  display: grid;
  gap: 12px;
}

.rank-select-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  margin-top: 0;
}

.rank-select-row .autocomplete {
  min-width: 0;
  width: 100%;
}

.rank-select-row .remove {
  white-space: nowrap;
  padding: 10px 14px;
}

.rank-card>.ghost {
  justify-self: start;
  margin-top: 2px;
  padding: 8px 14px;
}

@media (max-width: 900px) {
  #step-winners .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  #step-winners #load-winner-form {
    width: 100%;
    min-width: 0;
  }

  .step-pill+.step-pill {
    margin-left: 0;
  }
}

@media (max-width: 760px) {
  .payout-row,
  .rank-select-row {
    grid-template-columns: 1fr;
  }

  .rank-card > .ghost {
    justify-self: stretch;
  }
}

.rank-consumed {
  display: none !important;
}
