/* Score My Score. Night outside (the mirror ball), printed paper inside. */
:root {
  --paper: #f4ebdc;
  --card: #fffaf0;
  --ink: #1d1626;
  --muted: #6d6378;
  --soft: #e6dac6;
  --violet: #7d4fe0;
  --violet-soft: #e3d8ff;
  --sun: #f7cf4a;
  --danger: #c93a2c;
  --p1: #e8503a; --p2: #f08a24; --p3: #f2c230; --p4: #4dab6d;
  --p5: #3f8fd6; --p6: #5b5bd6; --p7: #a25bd1;
  --display: "Fraunces", Georgia, serif;
  --body: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --hand: "Caveat", "Bradley Hand", cursive;
  --lift: 4px;
  --ease: cubic-bezier(.2, .9, .3, 1.2);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink);
  font: 16px/1.5 var(--body);
  min-height: 100vh; min-height: 100dvh;
  /* faint paper tooth */
  background-image: radial-gradient(rgba(29, 22, 38, .045) 1px, transparent 1px);
  background-size: 14px 14px;
}
body.entry { background: #120c1a; background-image: none; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.12; margin: 0; text-wrap: balance; letter-spacing: -.01em; }
h2 { font-size: 26px; font-variation-settings: "SOFT" 100, "WONK" 1; }
h3 { font-size: 20px; }
p { margin: 0; text-wrap: pretty; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hand { font-family: var(--hand); font-size: 21px; line-height: 1.15; color: var(--violet); }
.loading { padding: 80px 16px; text-align: center; color: var(--muted); font-family: var(--hand); font-size: 24px; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; border-radius: 6px; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-18px) rotate(-3deg) scale(.96); } to { opacity: 1; transform: rotate(-.7deg); } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes wiggle { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px) rotate(-.7deg); } 40%, 80% { transform: translateX(6px) rotate(-.7deg); } }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 16px; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }

/* ---------------------------------------------------------- the logo */
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700;
  font-size: 22px; letter-spacing: -.02em; font-variation-settings: "SOFT" 100, "WONK" 1; }
.brand svg { width: 30px; height: 30px; flex: none; transition: transform .6s var(--ease); }
.brand:hover svg { transform: rotate(40deg) scale(1.08); }
.brand em { font-style: italic; color: var(--violet); }

/* ---------------------------------------------------------- entry (night) */
canvas.disco { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }
.entry-wrap {
  position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh;
  display: grid; justify-items: center; align-content: start; padding: 0 16px 48px;
}
.ball-slot { width: 100%; height: 40vh; min-height: 210px; }
body.no-gl .ball-slot {
  background: radial-gradient(circle at 50% 52%, #cfc6e6 0 4%, #6f5aa8 9%, #2a1e3d 14%, transparent 14.5%) no-repeat center;
}
.card {
  background: var(--card); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 22px;
  box-shadow: 7px 7px 0 var(--violet);
  padding: 26px 26px 22px; width: 100%; max-width: 400px;
  transform: rotate(-.7deg);
  animation: drop-in .6s var(--ease) both;
}
.card.shake { animation: shake .4s; }
.card .brand { font-size: 30px; }
.card .brand svg { width: 38px; height: 38px; }
.tagline { margin: 6px 0 20px; }
.entry-foot { margin-top: 18px; color: #b9aecb; font-family: var(--hand); font-size: 20px; text-align: center; animation: rise .6s .3s both; }
.sound-toggle {
  position: fixed; top: 14px; right: 14px; z-index: 5;
  width: 40px; height: 40px; border-radius: 50%; border: 2px solid currentColor; background: transparent;
  display: grid; place-items: center; color: #d9cfee; transition: transform .2s var(--ease);
}
.sound-toggle:hover { transform: scale(1.1) rotate(-6deg); }
.sound-toggle svg { width: 18px; height: 18px; }
header.top .sound-toggle { position: static; color: var(--ink); width: 34px; height: 34px; }

form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
input[type=text], input[type=email], input[type=password] {
  background: #fff; border: 2px solid var(--ink); border-radius: 12px;
  padding: 11px 13px; width: 100%; color: var(--ink);
  transition: box-shadow .15s, transform .15s;
}
input[type=text]:focus, input[type=email]:focus, input[type=password]:focus {
  outline: none; box-shadow: 4px 4px 0 var(--sun); transform: translate(-1px, -1px);
}
::placeholder { color: #a79dae; }

.btn {
  background: var(--violet); color: #fff; border: 2px solid var(--ink); border-radius: 12px;
  padding: 10px 18px; font-weight: 700;
  box-shadow: 0 var(--lift) 0 var(--ink);
  transition: transform .12s var(--ease), box-shadow .12s, background .15s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 calc(var(--lift) + 2px) 0 var(--ink); }
.btn:active:not(:disabled) { transform: translateY(var(--lift)); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { background: var(--soft); color: #9a8fa3; cursor: default; box-shadow: 0 var(--lift) 0 #b3a8ba; border-color: #b3a8ba; }
.btn.ghost { background: var(--card); color: var(--ink); }
.btn.danger { background: var(--card); color: var(--danger); }
.btn.sm { padding: 5px 11px; font-size: 14px; --lift: 3px; border-radius: 10px; }
.link { background: none; border: 0; padding: 0; color: inherit; font-weight: 600;
  text-decoration: underline; text-decoration-color: var(--violet); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.link:hover { text-decoration-style: wavy; }
.error { color: var(--danger); font-size: 14px; font-weight: 600; min-height: 1.4em; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* ---------------------------------------------------------- shell */
header.top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 16px 22px 6px; max-width: 980px; margin: 0 auto; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav button {
  background: none; border: 2px solid transparent; padding: 5px 13px; border-radius: 999px;
  font-weight: 600; transition: transform .15s var(--ease), background .15s;
}
nav button:hover { transform: translateY(-2px) rotate(-1.5deg); background: var(--soft); }
nav button[aria-current=page] { background: var(--ink); color: var(--card); transform: rotate(-1.5deg); }
.who { margin-left: auto; font-size: 14px; display: flex; align-items: center; gap: 10px; }
main { max-width: 720px; margin: 0 auto; padding: 18px 16px 90px; display: grid; gap: 22px; }
.view { display: grid; gap: 22px; }
.view > * { animation: rise .45s var(--ease) both; }
.view > *:nth-child(2) { animation-delay: .06s; }
.view > *:nth-child(3) { animation-delay: .12s; }
.view > *:nth-child(4) { animation-delay: .18s; }

/* five ratings, one upload */
.meter { position: relative; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 4px 2px; }
.tiles { display: flex; gap: 5px; }
.tiles i {
  width: 22px; height: 22px; border: 2px solid var(--ink); border-radius: 5px; background: var(--card);
  transition: transform .3s var(--ease), background .3s;
}
.tiles i.on { background: linear-gradient(135deg, #fff 0 22%, #cdbdf7 40%, var(--violet) 100%); transform: rotate(-6deg) translateY(-2px); }
.tiles i.on:nth-child(even) { transform: rotate(5deg) translateY(-1px); }
.ticket {
  background: var(--sun); border: 2px dashed var(--ink); border-radius: 8px; padding: 2px 12px;
  font-weight: 700; transform: rotate(-2deg); animation: pop .5s var(--ease) both, wiggle 2.4s 1s ease-in-out infinite;
}
.meter .counts { margin-left: auto; }
.burst { position: absolute; left: 60px; top: 14px; pointer-events: none; }
.burst i { position: absolute; width: 9px; height: 9px; border-radius: 2px; animation: fly .9s cubic-bezier(.1, .7, .3, 1) forwards; }

.panel {
  background: var(--card); border: 2px solid var(--ink); border-radius: 22px;
  box-shadow: 6px 6px 0 var(--ink); padding: 24px; display: grid; gap: 18px;
}
.song-title { font-family: var(--display); font-size: 30px; font-weight: 650; line-height: 1.08;
  overflow-wrap: anywhere; font-variation-settings: "SOFT" 100, "WONK" 1; }
.stack { display: grid; gap: 16px; }
.stack > * { animation: rise .4s var(--ease) both; }

/* ---------------------------------------------------------- sleeves */
.cover { flex: none; border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; background: var(--violet-soft);
  display: grid; place-items: center; box-shadow: 3px 3px 0 var(--ink); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; animation: rise .4s both; }
.cover svg { width: 46%; height: 46%; color: var(--ink); }
.cover.lg { width: 112px; height: 112px; transform: rotate(-2.5deg); }
.cover.md { width: 92px; height: 92px; transform: rotate(-2deg); margin-top: 6px; }
.cover.sm { width: 46px; height: 46px; border-radius: 9px; box-shadow: 2px 2px 0 var(--ink); }
.cover.mystery { background: var(--ink); }
.cover.mystery span { font-family: var(--display); font-size: 62px; font-weight: 700; color: var(--sun);
  font-variation-settings: "SOFT" 100, "WONK" 1; animation: wiggle 2.6s ease-in-out infinite; }
.song-head { display: flex; gap: 20px; align-items: center; }
.song-head > div:last-child { min-width: 0; }
.song-head.revealed .cover { animation: flip .6s var(--ease) both; }
.song-head.revealed > div:last-child { animation: rise .5s .15s both; }
@keyframes flip { from { transform: rotateY(90deg) rotate(-2.5deg); } to { transform: rotateY(0) rotate(-2.5deg); } }
@media (max-width: 560px) { .cover.lg { width: 84px; height: 84px; } .song-head { gap: 14px; } }

/* ---------------------------------------------------------- player */
.player { display: flex; align-items: center; gap: 14px; background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; padding: 7px 16px 7px 7px; }
.play {
  flex: none; width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--ink); background: var(--ink); color: var(--card);
  display: grid; place-items: center; transition: transform .15s var(--ease), background .15s;
}
.play:hover { transform: scale(1.08) rotate(-4deg); background: var(--violet); }
.play:active { transform: scale(.94); }
.play svg { width: 18px; height: 18px; }
.player.loading .play svg { animation: spin 1s linear infinite; }
.player input[type=range] { flex: 1; min-width: 0; appearance: none; -webkit-appearance: none; background: transparent; height: 22px; cursor: pointer; }
.player input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--ink) var(--pct, 0%), #cdbfae var(--pct, 0%)); }
.player input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: #cdbfae; }
.player input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--ink); }
.player input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5px;
  border-radius: 50%; background: var(--sun); border: 2px solid var(--ink); transition: transform .15s var(--ease); }
.player input[type=range]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: var(--sun); border: 2px solid var(--ink); }
.player input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.25); }
.player .time { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.eq { display: flex; gap: 2px; align-items: flex-end; height: 16px; width: 14px; flex: none; }
.eq i { width: 3px; height: 4px; background: var(--violet); border-radius: 1px; }
.player.playing .eq i { animation: eq .7s ease-in-out infinite; }
.player.playing .eq i:nth-child(2) { animation-delay: .2s; }
.player.playing .eq i:nth-child(3) { animation-delay: .4s; }

/* ---------------------------------------------------------- the seven keys */
.positions { display: grid; grid-template-columns: repeat(7, 1fr); gap: 9px; padding-bottom: 5px; }
.pos {
  --lift: 5px;
  background: var(--card); border: 2px solid var(--ink); border-radius: 14px;
  padding: 10px 2px 9px; display: grid; gap: 0; justify-items: center;
  box-shadow: 0 var(--lift) 0 var(--ink);
  border-top: 9px solid var(--c);
  transition: transform .12s var(--ease), box-shadow .12s, background .18s;
}
.pos b { font-family: var(--display); font-size: 28px; line-height: 1.1; font-weight: 700; font-variant-numeric: tabular-nums; }
.pos span { font-size: 12px; font-weight: 600; }
.pos:hover:not(:disabled) { transform: translateY(-3px) rotate(-1.5deg); box-shadow: 0 calc(var(--lift) + 3px) 0 var(--ink); }
.pos:nth-child(even):hover:not(:disabled) { transform: translateY(-3px) rotate(1.5deg); }
.pos[aria-pressed=true] { background: var(--c); transform: translateY(var(--lift)); box-shadow: 0 0 0 var(--ink); }
.pos[aria-pressed=true]:hover:not(:disabled) { transform: translateY(calc(var(--lift) - 1px)); box-shadow: 0 1px 0 var(--ink); }
@media (max-width: 560px) {
  .positions { grid-template-columns: repeat(4, 1fr); }
  .song-title { font-size: 25px; }
  .panel { padding: 18px; }
}

/* ---------------------------------------------------------- tally */
.tally { display: grid; gap: 8px; }
.tally-row { display: grid; grid-template-columns: 104px 1fr 62px; gap: 10px; align-items: center; font-size: 14px; }
.tally-row .name b { font-family: var(--display); font-size: 17px; margin-right: 6px; font-variant-numeric: tabular-nums; }
.bar { height: 18px; background: var(--paper); border: 2px solid var(--ink); border-radius: 9px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--c); border-right: 2px solid var(--ink); border-radius: 0 7px 7px 0;
  transform-origin: left; animation: grow .7s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i) * 60ms + 150ms); }
.bar i[style*="width:0%"] { border-right: 0; }
.tally-row .num { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.tally-row.mine .name { font-weight: 700; }
.tally-row.mine .name::after { content: " ●"; color: var(--c); }
.chips { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { font-size: 13px; font-weight: 700; padding: 1px 10px; border-radius: 999px; background: var(--c); border: 2px solid var(--ink);
  font-variant-numeric: tabular-nums; animation: pop .45s var(--ease) both; }
.mini { display: flex; gap: 3px; align-items: flex-end; height: 28px; flex: none; }
.mini i { width: 9px; background: var(--c); border: 1.5px solid var(--ink); border-radius: 3px; min-height: 5px; }
.mini i.zero { background: transparent; border-color: #c9bdab; }

/* ---------------------------------------------------------- upload */
.drop {
  border: 2.5px dashed var(--ink); border-radius: 18px; padding: 44px 20px; background: var(--paper);
  text-align: center; display: grid; gap: 10px; justify-items: center;
  transition: background .2s, transform .2s var(--ease);
}
.drop strong { font-family: var(--display); font-size: 24px; font-variation-settings: "SOFT" 100, "WONK" 1; }
.drop span { color: var(--muted); max-width: 42ch; }
.drop.over { background: var(--sun); transform: scale(1.02) rotate(-.6deg); }
.drop.over strong { animation: wiggle .5s ease-in-out infinite; }
progress { width: 100%; height: 12px; appearance: none; -webkit-appearance: none; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; background: var(--paper); }
progress::-webkit-progress-bar { background: var(--paper); }
progress::-webkit-progress-value { background: var(--violet); transition: width .2s; }
progress::-moz-progress-bar { background: var(--violet); }

/* ---------------------------------------------------------- lists */
.list { display: grid; gap: 12px; }
.item {
  background: var(--card); border: 2px solid var(--ink); border-radius: 16px; padding: 13px 16px; display: grid; gap: 14px;
  box-shadow: 3px 3px 0 var(--ink); transition: transform .15s var(--ease), box-shadow .15s;
}
.item:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.item-head { display: flex; gap: 14px; align-items: center; cursor: pointer; border-radius: 8px; }
.item-head .t { flex: 1; min-width: 0; }
.item-head .t strong { display: block; overflow-wrap: anywhere; font-family: var(--display); font-size: 18px; font-weight: 600; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1.5px solid var(--soft); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
td.wrap { white-space: normal; overflow-wrap: anywhere; min-width: 160px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px) rotate(-1deg);
  background: var(--ink); color: var(--card); border-radius: 12px; padding: 10px 18px; font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .3s var(--ease);
  max-width: calc(100vw - 32px); z-index: 10; box-shadow: 4px 4px 0 var(--violet);
}
#toast.show { opacity: 1; transform: translate(-50%, 0) rotate(-1deg); }

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