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

:root {
  --bg: #ffffff;
  --card: #f7f7f7;
  --accent: #000000;
  --text: #0a0a0a;
  --muted: #6f6f6f;
  --border: #d9d9d9;
}

* {
  box-sizing: border-box;
}

/* Prevent horizontal overflow from shifting the page's visual center */
html,
body {
  overflow-x: clip; /* fallback: use hidden if needed */
}

body {
  margin: 0;
  font-family: 'Poppins', 'Inter', 'Avenir Next', 'Helvetica Neue', 'Helvetica', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

/* Constrain header to the same centerline as main */
header {
  padding: 32px 24px 12px;
  text-align: center;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

header .logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.05em;
  color: #0a0a0a;
  padding: 6px 10px;
  font-family: 'Helvetica Neue', 'Helvetica', Arial, sans-serif;
  text-decoration: none;
}

header p {
  color: var(--text);
  margin: 8px 0 6px;
}

header .secondary {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 24px 60px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.controls {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 24px;

  width: min(680px, 100%);
  margin: 0 auto;

  display: block;
}

.featured {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  width: min(680px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.featured-header h2 {
  margin: 0;
  letter-spacing: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--muted);
}

.featured-card {
  display: block;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  padding: 0;
  background: transparent;
  appearance: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}

.featured-card img {
  width: 100%;
  height: 100%;
  display: block;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

form label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 4px;
}

form input,
form select {
  width: 100%;
  padding: 13px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  outline: none;
  font-size: 16px;
}

form input:focus,
form select:focus {
  border-color: #111;
}

.inline {
  display: flex;
  gap: 12px;
}

.field {
  flex: 1;
}

.muted {
  color: var(--muted);
  margin: 4px 0 0;
}

button[type='submit'] {
  margin-top: 4px;
  padding: 12px 20px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 10px;
  font-weight: 700;
  color: #ffffff;
  cursor: pointer;
  width: fit-content;
  transition: transform 0.08s ease;
  align-self: flex-start;
}

button[type='submit']:hover {
  transform: translateY(-1px);
}

button[type='submit']:active {
  transform: translateY(0);
}

.share {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 0;
  max-width: 360px;
  margin-left: auto;
}

.status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: #ffffff;
  display: none;
  align-items: center;
  overflow: auto;
}

.status.is-visible {
  display: flex;
}

.status.error {
  color: #c02626;
  font-weight: 600;
}

.share-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

/* Share actions */
.share-actions {
  display: flex;
  gap: 8px;
  align-items: stretch;

  flex: none;
  width: 100%;
  max-width: 360px;
}

.share-actions textarea {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  min-height: 44px;
  font-size: 14px;
  line-height: 1.2;
  resize: none;
}

.share-actions button {
  padding: 2px 12px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.2;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  align-self: stretch;
  flex: 0 0 120px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 4px;
}

.featured-label {
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  color: var(--muted);
  font-weight: 400;
  margin: 0 0 4px;
}

.ghost {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

/* Center toolbar to the same centerline as header/main */
.bracket-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 1200px;
  margin: 16px auto 12px;
  padding: 0 24px;
}

.bracket {
  display: grid;
  grid-template-columns: repeat(var(--round-count, 1), minmax(260px, 1fr));
  gap: 18px;
  margin-top: 6px;
  overflow: visible;
  width: 100%;
  justify-items: center;
  justify-content: center;
  align-content: start;
  align-items: start;
  grid-auto-rows: min-content;
}

.bracket.is-scrollable {
  max-height: 80vh;
  overflow-y: auto;
  padding-right: 8px;
}

.round {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-self: stretch;
  position: relative;
  align-items: stretch;
}

.round.final {
  align-self: start;
  justify-self: center;
}

.round h3 {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.02em;
  font-weight: 700;
}

.match {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 260px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.04);
}

.slot {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.1s ease, border 0.1s ease;
  background: var(--card);
  min-height: 96px;
}

.slot:hover {
  background: #f0f0f0;
  border-color: var(--border);
}

.slot.disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.slot.selected {
  border-color: var(--accent);
  background: #fafafa;
}

.cover-wrapper {
  position: relative;
  width: 82px;
  height: 82px;
  border-radius: 14px;
  overflow: hidden;
  background: #ececec;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.cover-wrapper.is-previewing::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--accent);
  pointer-events: none;
  border-radius: 14px;
}

.cover {
  width: 100%;
  height: 100%;
  border-radius: 14px;
  object-fit: cover;
}

.slot .meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.song-title {
  margin: 0;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-artist {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.placeholder {
  color: var(--muted);
  font-size: 13px;
}

.share-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 12px;
  background: rgba(0, 0, 0, 0.45);
  z-index: 20;
}

.share-modal.hidden {
  display: none;
}

.share-card {
  background: #fff;
  border-radius: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  width: min(520px, 100%);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.share-header {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  align-items: center;
}

.share-cover-frame {
  width: 120px;
  height: 120px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f0f0f0;
}

.share-cover-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
}

.share-meta h2 {
  margin: 6px 0 4px;
  font-size: 24px;
}

.share-card h2 {
  margin: 6px 0 4px;
  font-size: 24px;
}

.share-card .modal-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

/* Footer constrained to same centerline as header/main */
footer {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding: 22px 24px 32px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

footer p {
  margin: 0;
  text-align: center;
}

.footer-content {
  margin: 0;
  width: auto;
}

footer a {
  color: #0a6aff;
}

footer a:visited {
  color: #0a6aff;
}

footer a:hover {
  text-decoration: underline;
}

.confetti-piece {
  position: fixed;
  width: 10px;
  height: 14px;
  background: var(--accent);
  top: -10px;
  left: 0;
  opacity: 0.9;
  z-index: 0;
  will-change: transform;
  pointer-events: none;
}

@media (max-width: 720px) {
  .inline {
    flex-direction: column;
  }

  main {
    padding-left: 16px;
    padding-right: 16px;
  }

  .bracket {
    grid-template-columns: unset;
    grid-auto-columns: minmax(260px, 1fr);
    grid-auto-flow: column;
    justify-content: flex-start;
    justify-items: stretch;
    overflow-x: auto;
    overflow-y: visible;
    padding: 4px 12px 14px;
    margin: 0 -12px;
    scroll-snap-type: x proximity;
    scrollbar-gutter: stable both-edges;
    -webkit-overflow-scrolling: touch;
  }

  .bracket::-webkit-scrollbar {
    height: 10px;
  }

  .bracket::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 999px;
  }

  .bracket::-webkit-scrollbar-track {
    background: transparent;
  }

  .share {
    margin: 0;
    max-width: unset;
  }

  .share-modal {
    align-items: center;
    padding: 16px 10px;
  }

  .share-card {
    width: 100%;
    padding: 14px;
    gap: 10px;
    max-height: calc(100vh - 32px);
    max-height: min(620px, calc(100dvh - 32px));
    overflow-y: auto;
  }

  .share-header {
    grid-template-columns: 92px 1fr;
    gap: 10px;
  }

  .share-cover-frame {
    width: 92px;
    height: 92px;
  }

  .share-meta h2,
  .share-card h2 {
    font-size: 20px;
  }

  .share-top {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .share-actions {
    display: flex;
    gap: 8px;
    align-items: stretch;
    width: 100%;
    flex: none;
  }

  .round {
    min-width: 260px;
    width: 100%;
    scroll-snap-align: start;
  }

  .match {
    width: 100%;
  }

  .slot {
    grid-template-columns: 68px 1fr;
  }

  .cover-wrapper {
    width: 68px;
    height: 68px;
  }
}

/* Modal: make the textarea + Copy row span the full card width */
.share-card .share-actions {
  max-width: none;
  width: 100%;
}

/* Modal: make the textbox larger */
.share-card .share-actions textarea {
  min-height: 100px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.45;
}

/* Modal: keep Copy aligned with the right edge and sized nicely */
.share-card .share-actions button {
  flex: 0 0 96px;
  align-self: stretch;
}
