
/* twenty one pilots song sorter
   Palette: black, Blurryface red, ember orange, bone (text), ash (secondary text)
   Type: Big Shoulders Display for numbers and titles, Schibsted Grotesk for everything else */

:root {
  --black: #000;
  --ink: #f3eee7;
  --ash: #a39c94;
  --red: #e4262c;
  --red-deep: #b81a20;
  --ember: #ff7a1a;
  --panel: rgba(255, 255, 255, 0.05);
  --panel-strong: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.13);
  --radius: 16px;
  --display: "Big Shoulders Display", Impact, "Arial Narrow", sans-serif;
  --body: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

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

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(900px 520px at 8% -8%, rgba(228, 38, 44, 0.32), transparent 62%),
    radial-gradient(820px 520px at 100% 108%, rgba(255, 122, 26, 0.22), transparent 62%),
    var(--black);
  background-attachment: fixed;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

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

:focus-visible {
  outline: 3px solid var(--ember);
  outline-offset: 2px;
}

#app {
  width: min(1180px, 100% - 32px);
  margin: 0 auto;
  padding: 36px 0 24px;
}

/* ---------- masthead ---------- */

.masthead {
  text-align: center;
  margin-bottom: 28px;
}

.masthead h1 {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(46px, 9vw, 92px);
  line-height: 0.92;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.masthead h1 span {
  display: block;
  margin-top: 8px;
  font-weight: 700;
  font-size: 0.42em;
  letter-spacing: 0.32em;
  color: var(--ash);
}

.masthead p {
  margin-top: 16px;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

/* ---------- shared bits ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  font-weight: 600;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.btn-primary:hover {
  background: var(--ember);
  border-color: var(--ember);
  color: #000;
}

.btn-primary[disabled]:hover {
  background: var(--red);
  color: #fff;
}

.link-btn {
  background: none;
  border: 0;
  padding: 4px 2px;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-btn:hover {
  color: var(--ember);
}

/* ---------- album selection ---------- */

.select-head {
  text-align: center;
  margin-bottom: 18px;
}

.select-head h2 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 40px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.select-head p {
  color: var(--ash);
  margin-top: 4px;
}

.select-tools {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-top: 10px;
}

.resume {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  padding: 14px 18px;
  margin-bottom: 18px;
  border-color: rgba(255, 122, 26, 0.55);
}

.resume-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.resume .btn {
  min-height: 40px;
  padding: 0 18px;
}

.albums {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  padding-bottom: 4px;
}

.album {
  display: grid;
  grid-template-columns: auto 72px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: border-color 0.15s, opacity 0.15s;
}

.album.is-off {
  opacity: 0.5;
}

.album:has(input:checked),
.album:has(input:indeterminate) {
  border-color: rgba(255, 122, 26, 0.55);
}

.album input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--red);
  cursor: pointer;
}

.cover {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--red-deep), #2a0a0b);
}

.album-text {
  min-width: 0;
}

.album-title {
  font-weight: 700;
  font-size: 17px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.album-date {
  color: var(--ash);
  font-size: 14px;
  margin-top: 2px;
}

.songs-btn {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  font-size: 14px;
  white-space: nowrap;
}

.songs-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.startbar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin-top: 18px;
  padding: 34px 0 18px;
  text-align: center;
  background: linear-gradient(to top, #000 74%, rgba(0, 0, 0, 0));
}

.startbar .summary {
  color: var(--ash);
  font-size: 15px;
  margin-bottom: 12px;
}

.startbar .summary b {
  color: var(--ink);
}

.startbar .btn-primary {
  min-width: 260px;
  min-height: 54px;
  font-size: 18px;
}

/* ---------- song list dialog ---------- */

dialog {
  width: min(520px, 100% - 24px);
  max-height: min(80vh, 720px);
  padding: 0;
  color: var(--ink);
  background: #120808;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}

dialog[open] {
  display: flex;
  flex-direction: column;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.dlg-head {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.dlg-head .cover {
  width: 56px;
  height: 56px;
}

.dlg-head h2 {
  font-size: 19px;
  line-height: 1.2;
}

.dlg-head p {
  color: var(--ash);
  font-size: 14px;
}

.dlg-head .grow {
  flex: 1;
  min-width: 0;
}

.dlg-tools {
  display: flex;
  gap: 18px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
}

.dlg-list {
  overflow-y: auto;
  padding: 6px 8px;
  flex: 1;
}

.song-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.song-row:hover {
  background: var(--panel);
}

.song-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
  flex: none;
}

.song-row .t {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.song-row .nop {
  color: var(--ash);
  font-size: 13px;
  flex: none;
}

.dlg-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  text-align: right;
}

/* ---------- matchup ---------- */

.progress {
  padding: 18px 22px 20px;
  text-align: center;
  margin-bottom: 22px;
}

.progress h2 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 34px;
  letter-spacing: 0.03em;
  line-height: 1;
}

.progress h2 small {
  font-size: 0.58em;
  color: var(--ash);
  font-weight: 700;
  margin-left: 6px;
  letter-spacing: 0.04em;
}

.progress .stage {
  margin-top: 8px;
  color: var(--ember);
  font-weight: 600;
}

.bar {
  height: 8px;
  margin-top: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--ember));
  transition: width 0.3s;
}

.match {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: 22px;
}

.match.is-duel {
  max-width: 860px;
  margin: 0 auto;
}

.song-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px 20px 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.song-card.is-playing {
  border-color: var(--ember);
  box-shadow: 0 0 0 1px var(--ember);
}

.song-card.is-picked {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(228, 38, 44, 0.55);
}

.art {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--red-deep), #2a0a0b);
}

.art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-height: 40px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}

.play:hover:not([disabled]) {
  background: rgba(0, 0, 0, 0.82);
}

.play[disabled] {
  color: var(--ash);
  cursor: default;
}

.is-playing .play,
.is-playing .play:hover:not([disabled]) {
  background: var(--ember);
  border-color: var(--ember);
  color: #000;
}

.info {
  display: grid;
  gap: 4px;
}

.song-title {
  font-weight: 700;
  font-size: 22px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.song-album {
  color: var(--ash);
  font-size: 15px;
}

.choose {
  width: 100%;
  margin-top: auto;
}

.choose:hover {
  background: var(--red);
  border-color: var(--red);
}

.match-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.match-actions .link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ash);
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.match-actions .link-btn:hover:not([disabled]) {
  color: var(--ink);
  background: var(--panel-strong);
  border-color: var(--ember);
}

.match-actions .link-btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ---------- results ---------- */

.results-head {
  text-align: center;
  margin-bottom: 18px;
}

.results-head h2 {
  font-family: var(--display);
  font-weight: 900;
  font-size: 54px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.results-head p {
  color: var(--ash);
  margin-top: 6px;
}

.top-list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  width: min(680px, 100%);
}

.top-row {
  display: grid;
  grid-template-columns: 64px 56px 1fr;
  align-items: center;
  gap: 14px;
  padding: 10px 18px 10px 8px;
  border-bottom: 1px solid var(--line);
}

.top-row:last-child {
  border-bottom: 0;
}

.top-row .rank {
  font-family: var(--display);
  font-weight: 900;
  font-size: 46px;
  line-height: 1;
  text-align: center;
}

.top-row.r1 .rank {
  color: var(--ember);
  font-size: 56px;
}

.top-row.r2 .rank,
.top-row.r3 .rank {
  color: var(--red);
}

.top-row .cover {
  width: 56px;
  height: 56px;
}

.top-row .t {
  font-weight: 700;
  font-size: 18px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.top-row .a {
  color: var(--ash);
  font-size: 14px;
}

.top-wrap {
  padding: 4px 0;
  margin: 0 auto;
  width: min(680px, 100%);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 12px;
  margin-top: 22px;
}

.result-actions .btn {
  min-height: 48px;
  padding: 0 24px;
}

.result-actions .btn-primary {
  background: var(--red);
  border-color: var(--red);
}

.result-actions .btn-primary:hover {
  background: var(--ember);
  border-color: var(--ember);
  color: #000;
}

/* Download dropdown */

.download-menu {
  position: relative;
}

.download-menu > .btn {
  min-width: 180px;
}

.download-options {
  position: absolute;
  z-index: 10;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #120808;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}

.download-options[hidden] {
  display: none;
}

.download-options .btn {
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  background: var(--panel-strong);
}

.download-options .btn:hover {
  border-color: var(--ember);
  background: rgba(255, 255, 255, 0.14);
}

.result-note {
  text-align: center;
  color: var(--ash);
  font-size: 14px;
  margin-top: 16px;
}

/* ---------- misc ---------- */

.notice {
  max-width: 560px;
  margin: 40px auto;
  padding: 22px 24px;
  text-align: center;
}

.notice h2 {
  font-size: 22px;
  margin-bottom: 8px;
}

.notice p {
  color: var(--ash);
}

.notice code {
  color: var(--ink);
  background: var(--panel-strong);
  padding: 2px 6px;
  border-radius: 6px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  transform: translate(-50%, 20px);
  padding: 12px 20px;
  max-width: calc(100% - 32px);
  border-radius: 999px;
  background: var(--ink);
  color: #000;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- footer ---------- */

.site-footer {
  text-align: center;
  color: var(--ash);
  font-size: 13px;
  padding: 18px 16px 28px;
  letter-spacing: 0.04em;
}

.site-footer p {
  display: inline;
}

.site-footer a {
  color: var(--red);
  font-weight: 700;
  text-decoration: none;
  transition: color 0.15s;
}

.site-footer a:hover {
  color: var(--ember);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  #app {
    width: calc(100% - 24px);
    padding-top: 24px;
  }

  .match {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .song-card {
    display: grid;
    grid-template-columns: 112px 1fr;
    grid-template-areas:
      "art info"
      "art choose";
    align-items: center;
    column-gap: 14px;
    row-gap: 10px;
    padding: 12px;
    text-align: left;
  }

  .song-card .art {
    grid-area: art;
    width: 112px;
  }

  .song-card .info {
    grid-area: info;
  }

  .song-card .choose {
    grid-area: choose;
    margin-top: 0;
  }

  .song-title {
    font-size: 19px;
  }

  .play {
    min-height: 34px;
    padding: 0 14px;
    font-size: 13px;
  }

  .play .opt {
    display: none;
  }

  .album {
    grid-template-columns: auto 60px 1fr;
  }

  .album .cover {
    width: 60px;
    height: 60px;
  }

  .album .songs-btn {
    grid-column: 2 / -1;
    justify-self: start;
  }

  .top-row {
    grid-template-columns: 48px 48px 1fr;
    gap: 10px;
  }

  .top-row .rank {
    font-size: 38px;
  }

  .top-row.r1 .rank {
    font-size: 46px;
  }

  .top-row .cover {
    width: 48px;
    height: 48px;
  }

  .startbar .btn-primary {
    width: 100%;
  }

  .match-actions {
    gap: 10px;
  }

  .match-actions .link-btn {
    padding: 0 14px;
    font-size: 14px;
  }

  .result-actions {
    align-items: stretch;
  }

  .result-actions > .btn,
  .result-actions > .download-menu {
    flex: 1 1 100%;
  }

  .result-actions .btn {
    width: 100%;
  }

  .download-menu > .btn {
    width: 100%;
  }

  .download-options {
    position: static;
    margin-top: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
