/* The Cartridge Shelf — styles (mockup C, "Cartridge Shelf").
 *
 * Layout trick: #app and the routed view use display:contents, so the shelf
 * header, the mixtape (which lives OUTSIDE #app so the audio element never
 * re-mounts) and the shelves sit in one flex column and can be ordered.
 */

@font-face {
  font-family: "Press Start 2P";
  src: url("/fonts/press-start-2p-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Baloo 2";
  src: url("/fonts/baloo-2-latin-600-normal.woff2") format("woff2");
  font-weight: 600 700;
  font-display: swap;
}
@font-face {
  font-family: "Baloo 2";
  src: url("/fonts/baloo-2-latin-800-normal.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}
@font-face {
  font-family: "Sedgwick Ave Display";
  src: url("/fonts/sedgwick-ave-display-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --blue-top: #1B5490;
  --blue-bottom: #0F3862;
  --ink: #0C0C0C;
  --graffiti-ink: #0C0C0C;
  --text: #16202B;
  --muted: #5B6B7A;
  --paper: #FAFBFC;
  --shell: #D7DEE6;
  --steel: #93A4B5;
  --deck: #1C222B;
  --deck-2: #2E3745;
  --cassette: #EAF1F8;
  --pixel-magenta: #FF2E88;
  --pixel-cyan: #00D8D8;
  --pixel-gold: #FFC72C;
  --glow: #2BEBEB;
  --plank: #C9660A;
  --berry: #C81D68;
  --pixel: "Press Start 2P", ui-monospace, monospace;
  --round: "Baloo 2", "Segoe UI", system-ui, sans-serif;
  --graffiti: "Sedgwick Ave Display", "Baloo 2", sans-serif;
  --drop: 0 6px 0 rgba(0, 0, 0, 0.35);
}

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

html {
  min-height: 100%;
  background: linear-gradient(135deg, var(--blue-top) 0%, var(--blue-bottom) 100%) fixed;
  background-color: var(--blue-bottom);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0 auto;
  max-width: 440px;
  min-height: 100vh;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 24px;
  font-family: var(--round);
  font-weight: 600;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

#app,
.hub,
.game {
  display: contents;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--pixel-gold);
  outline-offset: 3px;
}

h1,
h2,
p {
  margin: 0;
}

/* ---------------------------------------------------------------- order */
.shelf-head { order: 1; }
#mixtape-host { order: 2; }
.shelf { order: 3; }
.unlock { order: 4; }
.game__back { order: 1; }
.game__box { order: 2; }
.game__playwrap { order: 3; }
.game__dest { order: 4; }
.game__panel { order: 5; }
.game__panel--scores { order: 6; }
#mixtape-host[data-route="game"] { order: 7; }
.foot { order: 9; }

/* ---------------------------------------------------------------- header */
.shelf-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.shelf-title {
  font-family: var(--graffiti);
  font-weight: 400;
  font-size: 44px;
  line-height: 44px;
  color: #FFFFFF;
  text-shadow: 4px 4px 0 var(--pixel-magenta);
}

.shelf-sub {
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 14px;
  color: var(--pixel-gold);
  white-space: nowrap;
  padding-bottom: 4px;
}

/* ---------------------------------------------------------------- mixtape */
.tape {
  background: var(--deck);
  border: 2px solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--drop);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--cassette);
}

.tape__cassette {
  background: var(--cassette);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text);
}

.tape__side {
  display: flex;
  justify-content: space-between;
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 14px;
}

.tape__window {
  height: 54px;
  background: var(--ink);
  border-radius: 27px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
}

.tape__reel {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 6px dotted var(--pixel-gold);
}

.tape--playing .tape__reel {
  animation: spin 2.4s linear infinite;
}

.tape__title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 15px;
  line-height: 20px;
  font-weight: 800;
  color: #FFFFFF;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tape__bar {
  height: 6px;
  background: var(--deck-2);
}

.tape__fill {
  width: 0;
  height: 100%;
  background: var(--glow);
  box-shadow: 0 0 8px var(--glow);
}

.tape__controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.tape__btn {
  height: 44px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--shell);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.tape__btn:active {
  transform: translateY(2px);
}

.tape__btn--play {
  background: var(--pixel-gold);
}

.tape__btn svg {
  display: block;
}

.tape__extra {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 14px;
}

.tape__mute {
  height: 32px;
  min-width: 44px;
  padding: 0 8px;
  border: 2px solid var(--ink);
  background: var(--shell);
  color: var(--ink);
  font-family: var(--pixel);
  font-size: 8px;
}

.tape__vol {
  flex: 1;
  accent-color: var(--pixel-gold);
  min-width: 0;
}

.tape__credit {
  margin-left: auto;
  color: var(--steel);
}

.tape__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: none;
  border-top: 2px dashed var(--deck-2);
}

.tape--list .tape__list {
  display: block;
}

.tape__item {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 10px 2px;
  border-bottom: 1px dashed var(--deck-2);
  cursor: pointer;
  font-size: 14px;
}

.tape__item--on {
  color: var(--pixel-gold);
}

.tape__num {
  font-family: var(--pixel);
  font-size: 8px;
  width: 20px;
}

.tape__name {
  flex: 1;
  font-weight: 700;
}

.tape__game {
  font-size: 12px;
  color: var(--steel);
}

/* empty tape: no songs yet, nothing to press */
.tape--empty .tape__controls,
.tape--empty .tape__extra,
.tape--empty .tape__bar {
  opacity: 0.45;
  pointer-events: none;
}

/* mini bar on a game page */
.tape--mini {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  box-shadow: none;
}

.tape--mini .tape__cassette,
.tape--mini .tape__bar,
.tape--mini .tape__extra,
.tape--mini .tape__list,
.tape--mini .tape__btn:not(.tape__btn--play) {
  display: none;
}

.tape__minireel {
  display: none;
}

.tape--mini .tape__minireel {
  display: block;
  width: 26px;
  height: 26px;
  border-width: 5px;
}

.tape__minititle {
  display: none;
}

.tape--mini .tape__minititle {
  display: block;
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tape--mini .tape__controls {
  display: block;
}

.tape--mini .tape__btn--play {
  width: 44px;
}

/* ---------------------------------------------------------------- shelf */
.shelf {
  display: flex;
  flex-direction: column;
}

.shelf-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 0 6px;
}

.shelf-plank {
  height: 16px;
  margin-bottom: 22px;
  background: var(--plank);
  border: 2px solid var(--ink);
  border-radius: 2px;
  box-shadow: var(--drop);
}

.cart {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  color: var(--text);
  transition: transform 0.2s ease;
}

.cart__grip {
  height: 14px;
  margin: 0 14px;
  background: repeating-linear-gradient(90deg, var(--steel) 0 4px, var(--muted) 4px 8px);
  border: 2px solid var(--ink);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
}

.cart__shell {
  flex: 1;
  background: var(--shell);
  border: 2px solid var(--ink);
  border-radius: 4px 4px 12px 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 176px;
}

.cart__art {
  flex: 1;
  min-height: 92px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 6px;
  background-size: cover;
  background-position: center;
}

.cart__name {
  align-self: flex-start;
  background: var(--paper);
  border: 2px solid var(--ink);
  padding: 3px 5px;
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 12px;
  color: var(--ink);
}

.cart__blurb {
  font-size: 13px;
  line-height: 18px;
  font-weight: 700;
}

.cart__new {
  position: absolute;
  top: 6px;
  right: -4px;
  background: var(--pixel-gold);
  border: 2px solid var(--ink);
  padding: 3px 5px;
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 10px;
  color: var(--ink);
  transform: rotate(6deg);
}

.cart:active .cart__shell {
  transform: translateY(2px);
}

.cart--pulling {
  transform: translateY(-14px);
}

.cart--locked .cart__shell {
  background: var(--muted);
}

.cart--locked .cart__art {
  background: repeating-linear-gradient(45deg, var(--deck-2) 0 6px, var(--deck) 6px 12px);
  justify-content: space-between;
}

.cart--locked .cart__blurb {
  color: #FFFFFF;
}

.cart__lock {
  align-self: center;
  margin-top: 8px;
}

.cart--shake {
  animation: shake 0.4s ease;
}

/* ---------------------------------------------------------------- panels */
.unlock,
.game__panel {
  background: var(--paper);
  border-radius: 16px;
  box-shadow: 0 6px 0 rgba(15, 42, 77, 0.18);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.unlock__title,
.panel__title {
  font-family: var(--pixel);
  font-size: 11px;
  line-height: 18px;
  font-weight: 400;
}

.unlock__text {
  font-size: 14px;
  line-height: 20px;
  color: var(--muted);
}

.unlock__row {
  display: flex;
  gap: 8px;
}

.unlock__input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #FFFFFF;
  color: var(--text);
  font-family: var(--pixel);
  font-size: 11px;
  text-transform: uppercase;
}

.unlock__btn {
  height: 44px;
  padding: 0 14px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--pixel-cyan);
  color: var(--ink);
  font-family: var(--pixel);
  font-size: 8px;
}

.unlock__btn:disabled {
  opacity: 0.6;
}

.unlock__msg {
  min-height: 14px;
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 14px;
  color: var(--berry);
}

.unlock__msg--ok {
  color: #1E8A55;
}

/* ---------------------------------------------------------------- footer */
.foot {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.foot__tag {
  font-family: var(--graffiti);
  font-size: 26px;
  line-height: 28px;
  color: var(--pixel-gold);
  text-shadow: 3px 3px 0 var(--ink);
  transform: rotate(-3deg);
}

.foot__note {
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 14px;
  color: #FFFFFF;
}

/* ---------------------------------------------------------------- game page */
.game__back {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--shell);
  text-decoration: none;
  color: var(--text);
  font-family: var(--pixel);
  font-size: 8px;
}

.game__box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game__grip {
  width: 220px;
  max-width: 60%;
  height: 18px;
  background: repeating-linear-gradient(90deg, var(--steel) 0 4px, var(--muted) 4px 8px);
  border: 2px solid var(--ink);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}

.game__shell {
  width: 100%;
  background: var(--shell);
  border: 2px solid var(--ink);
  border-radius: 6px 6px 18px 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--drop);
}

.game__cover {
  position: relative;
  height: 210px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 10px;
  background-size: cover;
  background-position: center;
}

.game__clip {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game__title {
  position: relative;
  align-self: flex-start;
  max-width: 100%;
  font-family: var(--graffiti);
  font-weight: 400;
  font-size: 40px;
  line-height: 40px;
  color: var(--ink);
  background: var(--paper);
  padding: 4px 10px;
  border: 2px solid var(--ink);
  text-shadow: 3px 3px 0 var(--pixel-magenta);
  overflow-wrap: anywhere;
}

.game__tags {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--paper);
  border: 1px solid var(--ink);
}

.pill--status {
  border-radius: 999px;
  border-color: transparent;
  background: var(--plank);
  color: var(--text);
}

.game__playwrap {
  filter: drop-shadow(2px 0 0 var(--ink)) drop-shadow(-2px 0 0 var(--ink)) drop-shadow(0 2px 0 var(--ink))
    drop-shadow(0 -2px 0 var(--ink)) drop-shadow(4px 4px 0 var(--ink));
}

.game__play {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 72px;
  border: 0;
  background: var(--pixel-cyan);
  color: var(--ink);
  font-family: var(--pixel);
  font-size: 14px;
  clip-path: polygon(0 8px, 8px 8px, 8px 0, calc(100% - 8px) 0, calc(100% - 8px) 8px, 100% 8px, 100% calc(100% - 8px),
    calc(100% - 8px) calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 8px calc(100% - 8px), 0 calc(100% - 8px));
}

.game__play:active {
  transform: translateY(2px);
}

.game__dest {
  margin-top: -12px;
  text-align: center;
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 14px;
  color: #FFFFFF;
}

.game__about {
  font-size: 16px;
  line-height: 24px;
}

.panel__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.panel__label {
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--muted);
}

.game__scores {
  list-style: none;
  margin: 0;
  padding: 0;
}

.game__scores li {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px dashed var(--steel);
  font-family: var(--pixel);
  font-size: 11px;
  line-height: 18px;
}

.game__scores .r {
  width: 32px;
  color: var(--berry);
}

.game__scores .n {
  flex: 1;
}

.game__scores .empty {
  font-size: 8px;
  color: var(--muted);
}

/* ---------------------------------------------------------------- press start */
body.pressing {
  overflow: hidden;
}

.press {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 12, 12, 0.72);
}

.press__card {
  width: min(360px, 100%);
  background: var(--shell);
  border: 2px solid var(--ink);
  border-radius: 6px 6px 18px 18px;
  box-shadow: var(--drop);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.press__studio {
  font-family: var(--graffiti);
  font-size: 24px;
  line-height: 26px;
  color: var(--pixel-gold);
  text-shadow: 2px 2px 0 var(--ink);
}

.press__title {
  font-family: var(--graffiti);
  font-weight: 400;
  font-size: 36px;
  line-height: 38px;
  color: #FFFFFF;
  text-shadow: 3px 3px 0 var(--pixel-magenta), -1px -1px 0 var(--ink), 1px 1px 0 var(--ink);
}

.press__btn {
  width: 100%;
  height: 64px;
  border: 0;
  background: var(--pixel-gold);
  color: var(--ink);
  font-family: var(--pixel);
  font-size: 14px;
  box-shadow: 0 0 0 2px var(--ink), 4px 4px 0 2px var(--ink);
  animation: blink 1.2s ease-in-out infinite;
}

/* ---------------------------------------------------------------- 404 */
.dusty {
  display: flex !important;
  flex-direction: column;
  gap: 14px;
  background: var(--paper);
  border-radius: 16px;
  box-shadow: var(--drop);
  padding: 22px 18px;
  margin-top: 40px;
}

.dusty__mark {
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--muted);
}

.dusty__title {
  font-family: var(--graffiti);
  font-weight: 400;
  font-size: 36px;
  line-height: 38px;
  text-shadow: 3px 3px 0 var(--pixel-magenta);
}

.dusty__body {
  font-size: 16px;
  line-height: 24px;
}

.dusty__link {
  align-self: flex-start;
  padding: 12px 14px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--pixel-cyan);
  color: var(--ink);
  font-family: var(--pixel);
  font-size: 8px;
  text-decoration: none;
}

/* ---------------------------------------------------------------- motion */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes blink {
  50% {
    opacity: 0.55;
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}

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