:root { --cream: #f3e6cf; --ink: #2b1d14; --glow: #ffcf8a; --accent: #e0894a; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d0806; color: var(--cream);
  font-family: "DM Mono", ui-monospace, monospace; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible { outline: 2px dashed var(--glow); outline-offset: 4px; }

#gl { position: fixed; inset: 0; }
#gl canvas { display: block; width: 100%; height: 100%; }
#gl.pointer { cursor: pointer; }
/* The YouTube player lives on this layer, mapped onto the TV screen in 3D. Nothing covers it. */
#css3d { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.tv3d { width: 640px; height: 480px; background: #000; opacity: 0; transition: opacity 1.2s ease; pointer-events: none;
  border-radius: 26px; overflow: hidden; }
.tv3d.on { opacity: 1; pointer-events: auto; }
.tv3d iframe, .tv3d #ytPlayer { width: 100%; height: 100%; border: 0; display: block; }

.loader { position: fixed; inset: 0; z-index: 200; display: grid; place-content: center; justify-items: center; gap: 18px;
  background: #0d0806; transition: opacity 1.2s; font-family: "Caveat", cursive; font-size: 26px; color: rgba(243,230,207,.7); }
.loader.gone { opacity: 0; pointer-events: none; }
.loader-rec { width: 90px; height: 90px; border-radius: 50%; animation: spin 1.8s linear infinite;
  background: radial-gradient(circle closest-side, #e0894a 0 30%, #111 31% 33%, transparent 34%), repeating-radial-gradient(circle closest-side, #1a1a1a 0 1px, #0b0b0b 1px 3px); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── HUD ───────────────────────────────────────────────── */
.hud { position: fixed; left: 0; right: 0; top: 0; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; z-index: 80; }
.hud-r { display: flex; gap: 8px; }
.brand { font-family: "Fraunces", serif; font-style: italic; font-size: 17px; color: rgba(243,230,207,.75); text-shadow: 0 2px 6px rgba(0,0,0,.6); }
.hud-btn { pointer-events: auto; height: 38px; min-width: 38px; border-radius: 999px; display: grid; place-items: center; background: rgba(20,12,8,.5); border: 1px solid rgba(243,230,207,.18); backdrop-filter: blur(8px); }
.hud-btn.wide { padding: 0 16px; font-size: 12px; letter-spacing: .04em; }
.hud-btn[hidden] { display: none; }
.hud-btn svg { width: 20px; height: 20px; fill: currentColor; }
.hud-btn.muted .wave { opacity: .15; }
.hint { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 80; font-size: 12px; letter-spacing: .04em; color: rgba(243,230,207,.7); background: rgba(20,12,8,.45); padding: 7px 15px; border-radius: 999px; backdrop-filter: blur(8px); transition: opacity .8s; white-space: nowrap; pointer-events: none; }
.hint.gone { opacity: 0; }
.tip { position: fixed; left: 0; top: 0; z-index: 85; pointer-events: none; padding: 4px 10px; border-radius: 6px; background: rgba(243,230,207,.92); color: var(--ink);
  font-family: "Caveat", cursive; font-weight: 700; font-size: 20px; opacity: 0; transform: translate(14px, 10px); transition: opacity .15s; white-space: nowrap; }
.tip.on { opacity: 1; }

.np { position: fixed; left: 16px; bottom: 16px; z-index: 80; display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 8px; width: min(360px, calc(100vw - 32px));
  background: rgba(20,12,8,.5); border: 1px solid rgba(243,230,207,.14); border-radius: 14px; backdrop-filter: blur(10px); transform: translateY(140%); transition: transform .6s cubic-bezier(.2,.9,.3,1); }
.np.on { transform: none; }
.np-art { width: 48px; height: 48px; border-radius: 6px; background: #2a1d14 center / cover; flex: none; box-shadow: 0 4px 10px rgba(0,0,0,.4); }
.np-text { flex: 1; min-width: 0; }
.np-side { font-size: 9.5px; text-transform: uppercase; letter-spacing: .16em; color: var(--accent); }
.np-title { font-family: "Fraunces", serif; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-sub { font-size: 11px; opacity: .65; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-ctrl { display: flex; gap: 4px; }
.np-ctrl button { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: rgba(243,230,207,.1); }
.np-ctrl button:hover { background: rgba(243,230,207,.2); }
.np-ctrl svg { width: 14px; height: 14px; fill: currentColor; }

/* ── overlays ─────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 60%, rgba(40,24,14,.78), rgba(8,5,3,.92)); backdrop-filter: blur(5px);
  animation: fade .35s ease; padding: 24px 16px; }
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.x { position: absolute; right: 18px; top: 14px; width: 42px; height: 42px; border-radius: 50%; font-size: 26px; line-height: 1; background: rgba(243,230,207,.08); }
.x:hover { background: rgba(243,230,207,.16); }
.dig-head { text-align: center; margin-bottom: 4px; }
.dig-kicker, .counter-kicker, .sb-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .2em; color: var(--accent); }
.dig-artist { font-family: "Fraunces", serif; font-weight: 600; font-size: clamp(30px, 5vw, 48px); margin: 4px 0 0; }

.crate-stage { position: relative; width: min(560px, 92vw); height: min(440px, 56vh); perspective: 1300px; perspective-origin: 50% -25%; --cs: 1; }
.crate-recs { position: absolute; inset: 0; transform-style: preserve-3d; }
.crec { --rec: min(300px, 34vh, 70vw); position: absolute; left: 50%; bottom: 60px; width: var(--rec); height: var(--rec); margin-left: calc(var(--rec) / -2); transform-origin: 50% 100%;
  transition: transform .5s cubic-bezier(.2,.85,.25,1), opacity .35s; border-radius: 3px; cursor: pointer;
  background: #2a1d14 center / cover; box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 14px 28px rgba(0,0,0,.55); }
.crec::after { content: ""; position: absolute; inset: 0; border-radius: 3px; background: linear-gradient(115deg, rgba(255,255,255,.14), transparent 40%); }
.crec.focus { box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 26px 40px rgba(0,0,0,.6), 0 0 60px rgba(255,190,110,.18); }
.crec .noart { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; font-family: "Fraunces", serif; font-size: 22px; }
.crate-front { position: absolute; left: 0; right: 0; bottom: 0; height: 168px; border-radius: 4px; transform: translateZ(40px);
  background: repeating-linear-gradient(#b98a52 0 50px, #7c5a33 50px 56px); box-shadow: inset 0 0 0 7px #8d6538, 0 24px 40px rgba(0,0,0,.55); display: grid; place-items: center; }
.crate-front span { font-family: "Fraunces", serif; font-style: italic; color: #4a3018; font-size: 20px; opacity: .7; background: rgba(241,229,203,.5); padding: 2px 16px; border-radius: 3px; }
.crate-loading { position: absolute; left: 0; right: 0; top: 40%; text-align: center; font-family: "Caveat", cursive; font-size: 30px; color: var(--cream); opacity: 0; transition: opacity .3s; pointer-events: none; }
.crate-loading.on { opacity: 1; }
.dig-meta { display: flex; align-items: center; gap: 18px; margin-top: 18px; }
.dig-now { min-width: 260px; max-width: 70vw; text-align: center; font-family: "Fraunces", serif; font-size: 20px; }
.dig-now small { display: block; font-family: "DM Mono"; font-size: 12px; opacity: .6; margin-top: 2px; }
.nav { width: 44px; height: 44px; border-radius: 50%; font-size: 26px; background: rgba(243,230,207,.08); }
.nav:hover { background: rgba(243,230,207,.18); }
.dig-hint { margin-top: 10px; font-size: 11px; opacity: .5; letter-spacing: .05em; text-align: center; }

.sleeve-view { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 56px; padding: 40px; flex-wrap: wrap;
  background: radial-gradient(ellipse at 40% 50%, rgba(50,30,18,.96), rgba(10,6,4,.98)); animation: fade .3s; overflow: auto; }
.sleeve-view[hidden] { display: none; }
.sleeve-left { position: relative; width: min(380px, 80vw); aspect-ratio: 1; flex: none; }
.sleeve-cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 3px; box-shadow: 0 30px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(0,0,0,.4); z-index: 2; background: #2a1d14; animation: pull .6s cubic-bezier(.2,.8,.2,1); }
@keyframes pull { from { transform: translateY(80px) scale(.9); opacity: 0; } }
.sleeve-vinyl { position: absolute; top: 3%; left: 3%; width: 94%; height: 94%; border-radius: 50%; z-index: 1;
  background: radial-gradient(circle closest-side, transparent 0 34%, #070707 34.5% 36%, transparent 36.5%), repeating-radial-gradient(circle closest-side, #181818 0 1px, #0b0b0b 1px 2.4px);
  box-shadow: 0 10px 30px rgba(0,0,0,.6); transform: translateX(0); transition: transform 1s cubic-bezier(.2,.8,.2,1) .25s; }
.sleeve-vinyl.out { transform: translateX(42%) rotate(40deg); }
.sv-label { position: absolute; inset: 33%; border-radius: 50%; background: #c9a36a center / cover; }
.sleeve-back { position: relative; z-index: 3; width: min(400px, 88vw); max-height: 80vh; display: flex; flex-direction: column; padding: 26px 28px; border-radius: 4px;
  background: linear-gradient(#f3e8cf, #e4d4b2); color: var(--ink); box-shadow: 0 30px 60px rgba(0,0,0,.5); animation: pull .6s .1s cubic-bezier(.2,.8,.2,1) backwards; }
.sleeve-back h3 { font-family: "Fraunces", serif; font-weight: 700; font-size: 28px; margin: 6px 0 0; line-height: 1.1; }
.sb-artist { font-family: "Caveat", cursive; font-size: 26px; color: #6b4a2e; }
.sb-tracks { margin: 14px 0; padding: 0 0 0 26px; overflow: auto; flex: 1; font-size: 13px; line-height: 1.85; min-height: 80px; }
.sb-tracks li { padding-left: 4px; }
.sb-tracks li span { float: right; opacity: .55; }
.sb-tracks li::marker { color: #a07a52; }
.sb-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { padding: 12px 18px; border-radius: 999px; font-size: 13px; letter-spacing: .03em; transition: transform .12s, background .2s; }
.btn.primary { background: #2f2118; color: #f6ead2; box-shadow: 0 4px 0 #120b07; }
.btn.primary:hover { background: #47311f; }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #120b07; }
.btn.ghost { color: inherit; box-shadow: inset 0 0 0 1.5px currentColor; opacity: .75; }

.counter { width: min(680px, 94vw); text-align: center; }
.counter h2 { font-family: "Fraunces", serif; font-weight: 400; font-style: italic; font-size: clamp(24px, 3.6vw, 34px); margin: 8px 0 22px; }
#backForm { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#backForm input { flex: 1; min-width: 220px; max-width: 420px; padding: 13px 18px; border-radius: 999px; border: 0; font: inherit; font-size: 15px; background: #f3e8cf; color: var(--ink); box-shadow: inset 0 2px 6px rgba(0,0,0,.25); outline: none; }
#backForm .btn.primary { background: var(--accent); color: #2a170a; box-shadow: 0 4px 0 #8a4a22; }
.rummage { margin-top: 30px; font-family: "Caveat", cursive; font-size: 28px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.rummage[hidden] { display: none; }
.rummage .crate-box { position: relative; left: 0; margin-top: 24px; }
.shake { animation: shake .5s ease-in-out infinite; }
@keyframes shake { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-2deg) translateX(-3px); } 75% { transform: rotate(2deg) translateX(3px); } }
.back-results { margin-top: 30px; display: flex; flex-wrap: wrap; gap: 32px 14px; justify-content: center; }
.back-results .card { position: relative; width: 190px; height: 86px; border-radius: 3px; background: linear-gradient(#f1e5cb, #ddcca8); color: var(--ink); text-align: left; padding: 30px 12px 8px;
  box-shadow: 0 8px 16px rgba(0,0,0,.45); animation: rise .5s cubic-bezier(.2,1.4,.4,1) backwards; transition: transform .2s; }
.back-results .card:hover { transform: translateY(-6px) rotate(-1deg); }
.back-results .card .tab { position: absolute; left: 10px; top: -24px; max-width: 170px; padding: 0 10px; height: 28px; line-height: 30px; border-radius: 6px 6px 0 0; background: #f1e5cb; font-family: "Caveat", cursive; font-weight: 700; font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back-results .card small { font-size: 11px; color: #8a6a4a; letter-spacing: .08em; text-transform: uppercase; }
.back-results .card .name { font-family: "Fraunces", serif; font-size: 15px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes rise { from { transform: translateY(60px); opacity: 0; } }
.back-results .none { font-family: "Caveat", cursive; font-size: 26px; opacity: .8; }

.toast { position: fixed; left: 50%; bottom: 54px; transform: translate(-50%, 20px); z-index: 120; max-width: min(520px, 92vw);
  background: #f3e8cf; color: var(--ink); padding: 11px 18px; border-radius: 10px; font-size: 13px; line-height: 1.45; text-align: center;
  box-shadow: 0 12px 30px rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .35s, transform .35s; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

.crate-box { position: relative; display: block; width: 176px; height: 80px; border-radius: 3px;
  background: repeating-linear-gradient(#b98a52 0 22px, #7c5a33 22px 26px); box-shadow: inset 0 0 0 4px #8d6538, 0 10px 14px rgba(0,0,0,.5); }
.crate-box i { position: absolute; top: -20px; width: 14px; height: 40px; border-radius: 2px 2px 0 0; display: block; }
.crate-box i:nth-child(1) { left: 26px; background: #3d5a73; transform: rotate(-8deg); }
.crate-box i:nth-child(2) { left: 70px; background: #c9533c; transform: rotate(4deg); height: 46px; }
.crate-box i:nth-child(3) { left: 118px; background: #e1b35a; transform: rotate(10deg); }
.overlay { z-index: 90; }
