:root {
    --bg: #1a1a2e; --bg-deep: #0d0d1a; --panel: #23233f;
    --purple: #7b2ff7; --pink: #ff2e97; --cyan: #00f5d4; --yellow: #ffe156; --green: #01875f;
}
* { box-sizing: border-box; }
body {
    margin: 0; background: var(--bg-deep); color: #e8e8f4;
    font-family: 'VT323', monospace; min-height: 100vh; overflow-x: hidden;
    background-image:
        linear-gradient(rgba(123,47,247,0.07) 2px, transparent 2px),
        linear-gradient(90deg, rgba(123,47,247,0.07) 2px, transparent 2px);
    background-size: 32px 32px;
}
img, canvas, .pix { image-rendering: pixelated; }
.pf { font-family: 'Press Start 2P', monospace; line-height: 1.6; }
.vt { font-family: 'VT323', monospace; }
.hidden { display: none; }

.px-box {
    background: var(--panel);
    box-shadow: 0 -4px 0 0 #000, 0 4px 0 0 #000, -4px 0 0 0 #000, 4px 0 0 0 #000,
                inset -4px -4px 0 0 rgba(0,0,0,0.35), inset 4px 4px 0 0 rgba(255,255,255,0.06);
    margin: 4px;
}
.px-inset { background: var(--bg-deep); box-shadow: inset 3px 3px 0 #000; }
.scroll-x { overflow-x: auto; }
.scroll-x::-webkit-scrollbar { height: 10px; }
.scroll-x::-webkit-scrollbar-thumb { background: var(--purple); }
.scroll-x::-webkit-scrollbar-track { background: #000; }

.px-btn {
    border: none; cursor: pointer; padding: 12px 16px; color: #fff; position: relative;
    box-shadow: 0 -3px 0 0 #000, 0 3px 0 0 #000, -3px 0 0 0 #000, 3px 0 0 0 #000, inset -3px -4px 0 0 rgba(0,0,0,0.35), inset 3px 3px 0 0 rgba(255,255,255,0.3);
    transition: transform 0.05s; text-decoration: none;
}
.px-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 -3px 0 0 #000, 0 3px 0 0 #000, -3px 0 0 0 #000, 3px 0 0 0 #000, inset 3px 3px 0 0 rgba(0,0,0,0.35); }
.px-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.px-green { background: var(--green); } .px-pink { background: var(--pink); } .px-purple { background: var(--purple); }
.px-cyan { background: var(--cyan); color: #0d0d1a; } .px-dark { background: #3a3a5c; }
.px-chip { background: #2e2e50; color: #ccc; border: none; padding: 4px 10px; cursor: pointer; box-shadow: 0 0 0 2px #000; }
.px-chip.on { background: var(--yellow); color: #0d0d1a; }
.px-select, .px-input { background: var(--bg-deep); color: #fff; border: none; padding: 6px 8px; box-shadow: 0 0 0 3px #000, inset 2px 2px 0 rgba(255,255,255,0.08); outline: none; }
.px-input:focus { box-shadow: 0 0 0 3px var(--cyan); }
.px-range { accent-color: var(--pink); }
.px-bar { height: 18px; background: #000; padding: 3px; cursor: pointer; }
.px-bar > div { height: 100%; transition: width 0.4s steps(8);
    background: repeating-linear-gradient(90deg, var(--cyan) 0 10px, #00c4aa 10px 12px); }
.seek > div { background: repeating-linear-gradient(90deg, var(--pink) 0 8px, #c0207a 8px 10px); }
.play-btn { width: 48px; height: 44px; padding: 0; }

.glitch-title { text-shadow: 2px 0 var(--pink), -2px 0 var(--cyan); animation: glitch 3s infinite steps(1); }
@keyframes glitch { 0%,90%,100% { text-shadow: 2px 0 var(--pink), -2px 0 var(--cyan); } 93% { text-shadow: -3px 1px var(--pink), 3px -1px var(--cyan); } 96% { text-shadow: 3px -2px var(--pink), -3px 2px var(--cyan); } }

/* Shell */
.app-shell { min-height: 100vh; }
.main-col { max-width: 1040px; margin: 0 auto; padding: 16px 12px 110px; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; display: flex; background: #12122a; border-top: 4px solid #000; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0 10px; background: none; border: none; color: #888; cursor: pointer; }
.tab.on { color: var(--yellow); background: #23233f; box-shadow: inset 0 4px 0 var(--green); }
@media (min-width: 900px) {
    .tabbar { top: 0; bottom: 0; right: auto; width: 88px; flex-direction: column; border-top: none; border-right: 4px solid #000; padding-top: 20px; }
    .tab { flex: 0; padding: 16px 0; }
    .tab.on { box-shadow: inset 4px 0 0 var(--green); }
    .main-col { padding: 24px 24px 40px 112px; max-width: 1150px; }
}

/* Store header */
.store-head { padding: 16px; }
.app-icon { width: 80px; height: 80px; background: linear-gradient(var(--purple), var(--pink)); box-shadow: 0 0 0 4px #000; flex-shrink: 0; object-fit: contain; }
.px-fallback { display: flex; align-items: center; justify-content: center; font-size: 28px; }
.stat-row { display: flex; justify-content: space-around; margin: 14px 0; text-align: center; }
.stat-row div { display: flex; flex-direction: column; font-size: 18px; }
.stat-row b { font-size: 22px; color: #fff; font-weight: normal; }
.stat-row span { color: #888; font-size: 15px; }
.rated { display: inline-block; background: var(--yellow); color: #000 !important; padding: 0 6px; margin: 0 auto; }
.shot { flex: 0 0 180px; height: 101px; position: relative; background: #000; box-shadow: 0 0 0 3px #000; overflow: hidden; }
.shot-cap { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.75); padding: 0 6px; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Level map */
.level-map { padding: 18px 16px 10px; }
.level-track { position: relative; display: flex; justify-content: space-between; padding-top: 34px; }
.level-track::before { content: ''; position: absolute; left: 16px; right: 16px; top: 52px; height: 4px; background: repeating-linear-gradient(90deg, #555 0 8px, transparent 8px 14px); }
.level-node { position: relative; z-index: 1; background: #3a3a5c; color: #aaa; border: none; padding: 6px 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; box-shadow: 0 0 0 3px #000; }
.level-node.active { background: var(--pink); color: #fff; }
.level-node.done { background: var(--green); color: #fff; }
.walker { position: absolute; top: -8px; transition: left 0.8s steps(10); }

/* Drop zones */
.drop-zone { padding: 36px 16px; text-align: center; cursor: pointer; outline: 4px dashed var(--purple); outline-offset: -12px; transition: outline-color 0.2s; }
.drop-zone:hover, .drop-zone.drag-over { outline-color: var(--cyan); background: #2a2a4c; }
.filmstrip { display: inline-flex; gap: 6px; background: #000; padding: 10px 8px; border-top: 6px dotted #888; border-bottom: 6px dotted #888; }
.filmstrip span { width: 32px; height: 24px; background: var(--purple); }
.filmstrip span:nth-child(2) { background: var(--pink); } .filmstrip span:nth-child(3) { background: var(--cyan); } .filmstrip span:nth-child(4) { background: var(--yellow); }
.pixel-keys { display: inline-flex; background: #000; padding: 4px; gap: 3px; }
.pixel-keys .k { width: 16px; height: 48px; background: #f5f5ff; position: relative; }
.pixel-keys .k.has-black::before { content: ''; position: absolute; left: -7px; top: 0; width: 10px; height: 28px; background: #111; z-index: 1; }

/* Clips */
.clip-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 640px) { .clip-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); } }
.clip-thumb { position: relative; overflow: hidden; transition: transform 0.15s steps(3); }
.clip-thumb:hover { animation: wiggle 0.4s steps(2) infinite; }
@keyframes wiggle { 0%,100% { transform: rotate(-1deg); } 50% { transform: rotate(1deg); } }
.thumb-vid { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; background: #000; }
.badge { background: #000; color: var(--cyan); padding: 0 6px; font-size: 16px; }
.badge-p { color: var(--yellow); }
.x-btn { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; background: var(--pink); color: #fff; border: none; cursor: pointer; box-shadow: 0 0 0 2px #000; font-size: 16px; line-height: 1; }
.mini-load { width: 50px; height: 10px; background: #000; padding: 2px; }
.mini-load div { height: 100%; background: var(--yellow); animation: load 1s steps(5) infinite; }
@keyframes load { from { width: 0; } to { width: 100%; } }
.coin-count { display: flex; align-items: center; gap: 6px; color: var(--yellow); }
.coin { width: 16px; height: 16px; background: var(--yellow); box-shadow: inset -3px -3px 0 #c9a800, 0 0 0 2px #000; animation: spinc 1s steps(4) infinite; }
@keyframes spinc { 0%,100% { transform: scaleX(1); } 50% { transform: scaleX(0.3); } }

/* Player */
.player-layout { display: grid; gap: 16px; }
@media (min-width: 900px) { .player-layout { grid-template-columns: 1fr 260px; align-items: start; } }
.crt { display: flex; flex-direction: column; align-items: center; }
.crt-bezel { width: 100%; background: linear-gradient(#d4d4d8, #a8a8b0); padding: 16px 16px 6px; border-radius: 14px; box-shadow: 0 0 0 4px #4a4a52, inset -6px -6px 0 rgba(0,0,0,0.15), inset 6px 6px 0 rgba(255,255,255,0.5); }
.crt-screen { position: relative; border-radius: 18px / 26px; overflow: hidden; background: #000; box-shadow: 0 0 0 4px #5a5a62; aspect-ratio: 16/9; }
.crt-canvas { width: 100%; height: 100%; display: block; }
.crt-scan { position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(0,0,0,0.12) 2px 4px); }
.crt-glow { position: absolute; inset: 0; pointer-events: none; border-radius: inherit; box-shadow: inset 0 0 0 2px rgba(80,255,120,0.6), inset 0 0 28px rgba(80,255,120,0.25), inset 0 0 80px rgba(0,0,0,0.5); }
.crt-chin { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 2px; }
.led { width: 10px; height: 10px; background: #3f3; box-shadow: 0 0 6px #3f3; }
.crt-neck { width: 60px; height: 26px; background: linear-gradient(90deg, #8a8a92, #b8b8c0, #8a8a92); box-shadow: 0 0 0 3px #4a4a52; }
.crt-foot { width: 180px; height: 22px; background: #c4c4cc; border-radius: 8px 8px 4px 4px; box-shadow: 0 0 0 4px #4a4a52; }
.crt:fullscreen { background: #333; justify-content: center; padding: 3vh; }
.crt:fullscreen .crt-bezel { max-width: 150vh; }
.fx-panel label { color: #ccc; }

/* Contest */
.theme-banner { text-align: center; padding: 20px; background: repeating-linear-gradient(45deg, #2b1f4f 0 12px, #23233f 12px 24px); }
.entry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.entry-card { overflow: hidden; }
.mini-crt { position: relative; aspect-ratio: 16/9; background: #000; cursor: pointer; border: 6px solid #b8b8c0; border-radius: 10px; margin: 8px; box-shadow: inset 0 0 0 2px rgba(80,255,120,0.5); overflow: hidden; }
.play-over { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 20px; text-shadow: 3px 3px 0 #000; background: rgba(0,0,0,0.2); }
.vote-btn { background: #2e2e50; color: #fff; border: none; padding: 2px 8px; cursor: pointer; box-shadow: 0 0 0 2px #000; }
.vote-btn.voted { background: var(--yellow); color: #000; }
.vote-btn:active { transform: translateY(2px); }

/* Leaderboard */
.arcade { background: #000; }
.hs-title { color: var(--pink); text-shadow: 3px 3px 0 var(--purple); animation: blink 1.2s steps(2) infinite; }
.hs-row { display: grid; grid-template-columns: 50px 50px 1fr 60px; gap: 8px; padding: 8px 4px; align-items: center; border-bottom: 2px dashed #222; }

/* Me */
.avatar { width: 72px; height: 72px; background: var(--purple); box-shadow: 0 0 0 4px #000; flex-shrink: 0; }
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 640px) { .badge-grid { grid-template-columns: repeat(6, 1fr); } }
.badge-card { text-align: center; padding: 10px 4px; }
.badge-card.locked { opacity: 0.4; }

/* Misc */
.toast-wrap { position: fixed; top: 14px; right: 14px; left: 14px; z-index: 10000; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; pointer-events: none; }
.toast-wrap .px-box { padding: 10px 14px; font-size: 20px; max-width: 360px; background: #12122a; color: var(--cyan); }
.tip { position: fixed; pointer-events: none; padding: 4px 8px; z-index: 100; color: var(--cyan); font-size: 18px; background: #000; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { max-width: 440px; width: 100%; }
.hs-flash { position: fixed; inset: 0; z-index: 9000; display: flex; align-items: center; justify-content: center; font-size: clamp(18px, 5vw, 48px); color: var(--yellow); text-shadow: 4px 4px 0 var(--pink); pointer-events: none; animation: blink 0.3s steps(2) infinite; background: rgba(0,0,0,0.4); }
.blink { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
@keyframes pulse-px { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.pulse-btn { animation: pulse-px 0.8s steps(2) infinite; }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.fade-slide-in { animation: fadeSlideIn 0.35s steps(5) forwards; }
.toast-enter { animation: fadeSlideIn 0.25s steps(4); }
@keyframes confetti-fall { 0% { transform: translateY(-10vh); opacity: 1; } 100% { transform: translateY(110vh); opacity: 0.6; } }
.confetti-piece { position: fixed; top: 0; z-index: 9999; pointer-events: none; animation: confetti-fall 3s steps(30) forwards; box-shadow: 0 0 0 1px #000; }