:root {
  --page: #22252d;
  --page-deep: #151821;
  --bar: #2c3038;
  --bar-dark: #171a22;
  --surface: #20242f;
  --surface-soft: #282d39;
  --surface-strong: #171b25;
  --ink: #f3f6ff;
  --muted: #b9c1d4;
  --line: rgba(167, 185, 226, 0.18);
  --line-strong: rgba(167, 185, 226, 0.32);
  --accent: #66c7ff;
  --accent-strong: #8d7dff;
  --purple: #8d7dff;
  --danger: #ff8ca8;
  --success: #82dfaa;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scrollbar-color: var(--accent) #171a22;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Bahnschrift, "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  letter-spacing: 0;
  background:
    linear-gradient(90deg, rgba(148, 163, 207, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(148, 163, 207, 0.025) 1px, transparent 1px),
    linear-gradient(180deg, var(--page) 0%, var(--page-deep) 100%);
  background-size: 44px 44px, 44px 44px, auto;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(102, 199, 255, 0.86), rgba(141, 125, 255, 0.72));
  opacity: 0.11;
  -webkit-mask: url("letter_S_mark.png") center 50% / min(720px, 70vw) auto no-repeat;
  mask: url("letter_S_mark.png") center 50% / min(720px, 70vw) auto no-repeat;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  text-transform: uppercase;
}

h1 {
  max-width: 16ch;
  margin-bottom: 1rem;
  font-size: 3.7rem;
  line-height: 0.95;
  font-style: italic;
  font-weight: 900;
}

h2 {
  margin-bottom: 0;
  font-size: 2rem;
  line-height: 1;
  font-style: italic;
  font-weight: 900;
}

p {
  line-height: 1.6;
}

.site-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  align-items: center;
  min-height: 70px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.28);
  background: linear-gradient(180deg, #30343d, var(--bar-dark));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.26);
}

.site-topbar::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 360px;
  height: 6px;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  clip-path: polygon(0 0, 100% 0, calc(100% - 16px) 100%, 0 100%);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 70px;
  padding: 0 2rem;
  color: #ffffff;
  text-decoration: none;
  text-transform: uppercase;
  font-size: 1.45rem;
  font-weight: 900;
  font-style: italic;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(167, 185, 226, 0.26);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(102, 199, 255, 0.2), rgba(141, 125, 255, 0.2));
  box-shadow: inset 0 0 22px rgba(102, 199, 255, 0.12);
  overflow: hidden;
}

.brand-mark img {
  width: 31px;
  height: auto;
  object-fit: contain;
  filter: invert(1);
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 1rem;
  padding-right: 1.4rem;
}

.top-nav a {
  color: #f2f5ff;
  text-decoration: none;
  text-transform: uppercase;
  font-size: 0.9rem;
  font-weight: 900;
  font-style: italic;
  opacity: 0.88;
}

.top-nav a:hover {
  color: var(--accent);
}

.topbar-cta,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.55rem;
  color: #ffffff;
  text-decoration: none;
  text-transform: uppercase;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 900;
  font-style: italic;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  box-shadow: 0 10px 22px rgba(102, 199, 255, 0.22);
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

.topbar-cta {
  margin-right: 2rem;
}

.topbar-cta:hover,
.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(141, 125, 255, 0.24);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3.2rem 0 4rem;
}

.hero-card,
.calculator-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(43, 48, 61, 0.94), rgba(30, 34, 45, 0.94));
  box-shadow: var(--shadow);
}

.hero-card::before,
.calculator-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--purple));
}

.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.35rem;
  align-items: center;
  min-height: 280px;
  padding: 2.4rem min(32vw, 26rem) 2.4rem 2.4rem;
  margin-bottom: 1.25rem;
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(30, 34, 45, 0.98) 0%, rgba(30, 34, 45, 0.88) 48%, rgba(30, 34, 45, 0.34) 100%),
    linear-gradient(180deg, rgba(102, 199, 255, 0.08), rgba(141, 125, 255, 0.12));
  pointer-events: none;
}

.hero-bg-image {
  position: absolute;
  inset: 0 0 0 auto;
  z-index: 0;
  width: min(64%, 760px);
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0.7;
  filter: saturate(0.9) contrast(1.08) brightness(0.72);
}

.hero-card > .eyebrow,
.hero-card > h1,
.hero-card > .hero-copy {
  position: relative;
  z-index: 2;
  grid-column: 1;
}

.calculator-card {
  padding: 2rem;
}

.eyebrow,
.section-label,
.result-label {
  margin: 0 0 0.55rem;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 900;
  font-style: italic;
}

.eyebrow {
  color: var(--accent);
}

.hero-copy {
  max-width: 62ch;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.06rem;
}

.card-header,
.signup-section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.35rem;
}

.form-block {
  position: relative;
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.018));
}

.form-block:first-of-type {
  margin-top: 0;
}

.tournament-select-block {
  border-color: rgba(102, 199, 255, 0.28);
  background:
    linear-gradient(135deg, rgba(102, 199, 255, 0.08), rgba(141, 125, 255, 0.07)),
    rgba(255, 255, 255, 0.025);
}

.form-block::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--purple));
  opacity: 0.9;
}

.form-block-heading {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.2fr);
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
}

.form-block-heading h3,
.signup-section-header h3 {
  margin-bottom: 0;
  font-size: 1.35rem;
  line-height: 1;
  font-style: italic;
}

.form-block-heading p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.final-block {
  border-color: rgba(102, 199, 255, 0.28);
}

.header-actions,
.submission-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
}

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.tab-button,
.ghost-button,
.remove-slot-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.82rem 1.05rem;
  font: inherit;
  font-weight: 800;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.tab-button:hover,
.tab-button.is-active,
.ghost-button:hover:not(:disabled) {
  transform: translateY(-1px);
  color: var(--ink);
  border-color: rgba(102, 199, 255, 0.45);
  background: rgba(102, 199, 255, 0.08);
}

.remove-slot-button {
  color: var(--danger);
  border-color: rgba(255, 140, 168, 0.34);
  background: rgba(255, 140, 168, 0.08);
}

.tool-view {
  display: none;
}

.tool-view.is-active {
  display: block;
}

.meta-grid,
.tournament-signup-grid,
.signup-layout-grid,
.rank-grid,
.contact-grid,
.calculator-import-panel,
.results-panel {
  display: grid;
  gap: 1rem;
}

.meta-grid {
  grid-template-columns: minmax(260px, 1.1fr) minmax(120px, 0.45fr) minmax(0, 0.9fr);
  margin-bottom: 1rem;
}

.tournament-signup-grid {
  grid-template-columns: minmax(260px, 0.5fr) minmax(0, 1fr);
  align-items: stretch;
}

.tournament-details-card {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid rgba(102, 199, 255, 0.22);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.tournament-details-card > span {
  grid-column: 1 / -1;
  align-self: center;
  color: var(--muted);
  font-weight: 800;
}

.tournament-details-card div {
  display: grid;
  gap: 0.25rem;
  min-height: 64px;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.tournament-details-card span {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 900;
}

.tournament-details-card strong {
  color: var(--ink);
}

.calculator-meta-grid {
  margin-bottom: 0;
}

.signup-meta-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 0;
}

.signup-layout-grid {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.38fr);
  align-items: stretch;
}

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

.calculator-rank-grid {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.signup-roster-grid,
.contact-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.calculator-import-panel {
  grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1fr);
  margin: 1rem 0;
}

.results-panel {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 1rem;
}

.signup-core-panel,
.logo-upload-panel,
.signup-callout,
.meta-card,
.contact-card,
.player-card,
.result-box,
.submission-panel,
.agreement-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.signup-core-panel {
  padding: 1rem;
}

.logo-upload-panel {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
}

.logo-preview {
  display: grid;
  place-items: center;
  min-height: 168px;
  border: 1px dashed rgba(167, 185, 226, 0.42);
  border-radius: 8px;
  color: var(--muted);
  background:
    linear-gradient(135deg, rgba(102, 199, 255, 0.08), rgba(141, 125, 255, 0.05)),
    rgba(7, 10, 16, 0.28);
  overflow: hidden;
}

.logo-preview.has-logo {
  border-style: solid;
  background: rgba(255, 255, 255, 0.065);
}

.logo-preview img {
  width: min(180px, 82%);
  max-height: 136px;
  object-fit: contain;
}

.logo-upload-control {
  display: grid;
  gap: 0.55rem;
  font-weight: 900;
}

.logo-upload-control input,
.import-card input {
  padding: 0;
  border: 0;
  background: transparent;
}

.logo-upload-panel p,
.signup-callout p,
.import-card p,
.meta-copy p {
  margin-bottom: 0;
  color: var(--muted);
}

.signup-callout {
  display: grid;
  gap: 0.35rem;
  margin: 1rem 0 0;
  padding: 1rem;
  border-left: 5px solid var(--accent);
}

.signup-callout span,
.meta-card span,
.contact-card span,
.player-card span {
  color: var(--ink);
  font-weight: 900;
}

.compact-button {
  width: fit-content;
  padding: 0.72rem 0.95rem;
}

.meta-card,
.contact-card,
.player-card {
  display: grid;
  gap: 0.65rem;
  padding: 1rem;
}

.rank-select-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 0.65rem;
  align-items: center;
}

.rank-icon-preview {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(167, 185, 226, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(102, 199, 255, 0.08), rgba(141, 125, 255, 0.08)),
    rgba(0, 0, 0, 0.16);
}

.rank-icon-preview img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.36));
}

.rank-icon-preview img.is-muted {
  opacity: 0.32;
  filter: grayscale(1);
}

.average-rank-image {
  display: block;
  width: min(96px, 42%);
  height: 96px;
  object-fit: contain;
  margin: 0.25rem auto 0.65rem;
  opacity: 0.82;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.42));
}

.average-rank-image.is-muted {
  opacity: 0.18;
  filter: grayscale(1);
}

.attached-rank-summary {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
}

.attached-rank-summary img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  opacity: 0.76;
}

.attached-rank-summary img.is-muted {
  opacity: 0.2;
  filter: grayscale(1);
}

.attached-rank-summary p {
  margin: 0;
}

.signup-section-header {
  margin-top: 1.5rem;
}

.form-block .signup-section-header {
  margin-top: 0;
}

.signup-notes {
  margin-bottom: 1rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(167, 185, 226, 0.16);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  font: inherit;
  color: #ffffff;
  background: #171b25;
  outline: none;
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

input::placeholder,
textarea::placeholder {
  color: rgba(243, 246, 255, 0.44);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(102, 199, 255, 0.16);
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #ffffff 50%),
    linear-gradient(135deg, #ffffff 50%, transparent 50%);
  background-position:
    calc(100% - 20px) calc(50% - 3px),
    calc(100% - 14px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.8rem;
}

select option {
  color: #ffffff;
  background: #171b25;
}

.result-box {
  padding: 1.25rem;
}

.result-box strong {
  font-size: 2.35rem;
}

.result-box.accent {
  border-color: rgba(141, 125, 255, 0.42);
  background: rgba(141, 125, 255, 0.12);
}

.submission-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
  padding: 1rem;
}

.agreement-grid {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0;
}

.agreement-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  color: var(--muted);
}

.agreement-card input {
  width: auto;
  margin-top: 0.2rem;
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  box-shadow: none;
}

.status-message {
  margin-bottom: 0;
  color: var(--muted);
  text-align: right;
}

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

.status-message.is-success {
  color: var(--success);
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.85rem;
  margin-top: 1.5rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
  text-transform: uppercase;
  font-size: 0.82rem;
  font-weight: 800;
}

.site-footer a:hover {
  color: var(--accent);
}

.organizer-results,
.organizer-payload {
  margin-top: 1.25rem;
}

.organizer-payload pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  font: 0.95rem/1.5 Consolas, "Courier New", monospace;
}

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

  .site-topbar {
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
  }

  .brand-lockup {
    min-height: auto;
    padding: 0;
  }

  .top-nav {
    grid-column: 1 / -1;
    justify-content: center;
    padding-right: 0;
  }

  .topbar-cta {
    margin-right: 0;
  }

  .hero-card,
  .form-block-heading,
  .signup-layout-grid,
  .tournament-signup-grid,
  .calculator-import-panel {
    grid-template-columns: 1fr;
  }

  .hero-card {
    padding-right: min(24vw, 16rem);
  }

  .hero-bg-image {
    width: min(72%, 620px);
  }

  .rank-grid,
  .contact-grid,
  .signup-meta-grid,
  .signup-roster-grid,
  .tournament-details-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  body::after {
    -webkit-mask-size: min(440px, 86vw) auto;
    mask-size: min(440px, 86vw) auto;
  }

  h1 {
    font-size: 2.45rem;
  }

  h2 {
    font-size: 1.65rem;
  }

  .site-topbar {
    position: relative;
  }

  .site-topbar::after {
    width: 220px;
  }

  .brand-lockup {
    font-size: 1.05rem;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand-mark img {
    width: 27px;
    height: auto;
  }

  .top-nav {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .topbar-cta {
    min-height: 40px;
    padding: 0.7rem 1rem;
  }

  .app-shell {
    width: min(100% - 1rem, 100%);
    padding: 1rem 0 2rem;
  }

  .hero-card,
  .calculator-card {
    padding: 1.25rem;
  }

  .form-block {
    padding: 1rem 0.85rem 0.85rem;
  }

  .hero-bg-image {
    width: 100%;
    opacity: 0.34;
  }

  .hero-card::after {
    background:
      linear-gradient(90deg, rgba(30, 34, 45, 0.98) 0%, rgba(30, 34, 45, 0.9) 70%, rgba(30, 34, 45, 0.72) 100%),
      linear-gradient(180deg, rgba(102, 199, 255, 0.08), rgba(141, 125, 255, 0.12));
  }

  .meta-grid,
  .card-header,
  .results-panel,
  .rank-grid,
  .contact-grid,
  .signup-meta-grid,
  .signup-roster-grid,
  .signup-layout-grid,
  .tournament-signup-grid,
  .tournament-details-card,
  .signup-section-header,
  .form-block-heading {
    grid-template-columns: 1fr;
  }

  .card-header,
  .signup-section-header {
    display: grid;
  }

  .header-actions {
    justify-content: stretch;
  }

  .submission-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .submission-actions {
    flex-direction: column;
  }

  .status-message {
    text-align: left;
  }
}
